Part Number Hot Search : 
4C225K05 UFT7260 LA1844M 25N05 4066D KIA79 KBPC610 TFS150Y
Product Description
Full Text Search
 

To Download S3F82NB Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ps031601-0813 preliminary copyright ?2013 zilog ? , inc. all rights reserved. www.zilog.com product specification s3 family 8-bit microcontrollers S3F82NB
ps031601-0813 p r e l i m i n a r y S3F82NB product specification ii do not use this product in life support systems. life support policy zilog?s products are not authorized for use as critical components in life support devices or systems without th e express prior written approval of the president and general counsel of zilog corporation. as used herein life support devices or systems are devices which (a) are intended for surgical impl ant into the body, or (b) support or sustain life and whose failure to perform when properly used in accordance with instructions for use provided in the labeling can be reasonably expected to result in a signi ficant injury to the user. a criti- cal component is any component in a life support device or system whose failure to perform can be reason- ably expected to cause the failure of the life support devi ce or system or to affect its safety or effectiveness. document disclaimer ?2013 zilog, inc. all rights reserved . information in this pu blication concerning the devices, applications, or technology described is intend ed to suggest possible uses and may be superseded. zilog, inc. does not assume liability for or provide a representation of accuracy of the information, devices, or technology described in this document. zilog also does not assume liability for intellectual property infringement related in any manner to use of information, devices, or technology described herein or otherwise. the information contained w ithin this document has been verified according to the general principles of electrical and mechanical engineering. s3 and z8 are trademarks or registered trademarks of zilog, inc. all other product or service names are the property of their respective owners. warning:
ps031601-0813 p r e l i m i n a r y revision history S3F82NB product specification iii revision history each instance in this document?s revision history reflects a change from its previous edi- tion. for more details, refer to the corresponding page(s) or appropriate links furnished in the table below. date revision level description page aug 2013 01 original zilog issue. a table of cont ents and pdf bookma rks will appear in the next edition, due to be published on or before winter 2013. all
1 product overview s3c8-series microcontrollers samsung's s3c8 series of 8-bit single-chip cmos microcontrollers offers a fast and efficient cpu, a wide range of integrated peripherals, and various mask-programmable rom sizes. among the major cpu features are: efficient register-oriented architecture selectable cpu clock sources idle and stop power-down mode release by interrupts built-in basic timer with watchdog function a sophisticated interrupt structure recognizes up to eight interrupt levels. each level can have one or more interrupt sources and vectors. fast interrupt processing (within a minimum of four cpu clocks) can be assigned to specific interrupt levels. S3F82NB microcontroller the S3F82NB single-chip cmos microcontrollers are fabricated using the highly advanced cmos process, based on samsungs newest cpu architecture. the S3F82NB is a microcontroller with a 64k-byte flash rom embedded. using a proven modular design approach, samsung engineers have successfully developed the S3F82NB by integrating the following peripheral modules with the powerful sam8 core: eleven programmable i/o ports, including ten 8- bit ports, and one 3-bit port, for a total of 83 pins twelve bit-programmable pins for external interrupts one 8-bit basic timer for oscillation stabilization and watchdog functions (system reset) one 8-bit timer/counter and one 16-bit timer/counter with selectable operating modes watch timer for real time lcd controller/driver a/d converter with 8 selectable input pins synchronous sio modules comparator they are currently available in 128-pin qfp package ps031601-0813 p r e l i m i n a r y S3F82NB product specification 1
features cpu ? sam88 rc cpu core memory ? program memory (rom) - 64k  8 bits program memory - internal flash memory (program memory)  sector size: 128 bytes  10 years data retention  fast programming time:  user program and sector erase available  endurance: 10,000 erase/program cycles  external serial programming support  expandable obp tm (on board program) sector ? data memory (ram) - including lcd display data memory - 4,112  8 bits data memory instruction set ? 78 instructions ? idle and stop instructions added for power-down modes 83 i/o pins ? i/o: 19 pins (sharing with other signal pins) ? i/o: 64 pins (sharing with lcd signal outputs) interrupts ? 8 interrupt levels and 19 interrupt sources ? fast interrupt processing feature 8-bit basic timer ? watchdog timer function ? 4 kinds of clock source 8-bit timer/counter 0 ? programmable 8-bit internal timer ? external event counter function ? pwm and capture function timer/counter 1 ? programmable 16-bit internal timer ? two 8-bit timer/counters a/b mode ? pwm and capture function ? external event counter function watch timer ? interval time: 3.91ms, 0.125s, 0.25s, and 0.5s at 32.768 khz ? 0.5/1/2/4 khz selectable buzzer output lcd controller/driver ? 80 segments and 16 common terminals ? 1/8 and 1/16 duty selectable ? internal resistor bias selectable ? 16 level lcd contrast control by software analog to digital converter ? 8-channel analog input ? 10-bit conversion resolution ? 25us conversion time 8-bit serial i/o interface ? 8-bit transmit/receive mode ? 8-bit receive mode ? lsb-first or msb-first transmission selectable ? internal or external clock source comparator ? 3-channel mode: internal reference (4-bit resolution); 16-step variable reference voltage ? 2-channel mode: external reference low voltage reset (lvr) ? criteria voltage: 2.0v ? en/disable by smart option (rom address: 3fh) two power-down modes ? idle: only cpu clock stops ? stop: selected system clock and cpu clock stop oscillation sources ? crystal, ceramic, or rc for main clock ? main clock frequency: 0.4 mhz  12.0 mhz ? 32.768 khz crystal oscillation circuit for sub clock instruction execution times ? 333ns at 12.0 mhz fx (minimum) ? 122.1us at 32.768 khz fxt (minimum) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 2
features (continued) operating voltage range ? 1.8 v to 5.5 v at 0.4  4.2 mhz ? 2.2 v to 5.5 v at 0.4  12.0 mhz operating temperature range ?  40 c to + 85 c package type ? 128-qfp-1420 smart option ? low voltage reset (lvr) enable/disable and av ref or p1.0/int0 selection are at your hardwired option (rom address 3fh) ? isp related option selectable (rom address 3eh) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 3
block diagram nreset v dd port i/o and interrupt control sam88rc cpu 64 k-byte rom 4,112 byte register file x in basic timer 8-bit timer/counter0 comparator sio lcd controller/ driver v ss x out xt in xt out watchdog timer t0clk/ad1/p0.1 t 0out/t0pwm/t0cap/ad3/p0.3 8-bit timera 8-bit timerb timer 1 t1clk/ad0/p0.0 t 1out/t1pwm/t1cap/ad2/p0.2 10-bit adc ad0-ad7/p0.0-p0.7 cin0/p6.0 cin1/p6.1 cin2/p6.2 sck/int7/p1.7 so/int6/p1.6 si/int5/p1.5 v lc0 -v lc4 com0-com7 com8-com15/seg0-seg7 seg56-seg87/p3.0-p5.7 seg8-seg55 port 0 p0.0/ad0/t1clk p0.1/ad1/t0clk p 0.2/ad2/t1out/t1pwm/t1cap p 0.3/ad3/t0out/t0pwm/t0cap p0.4/ad4 p0.5/ad5 p0.6/ad6 p0.7/ad7 port 1 p1.0/int0/v ref p1.1/int1 p1.2/int2 p1.3/int3 p1.4/int4/buz p1.5/int5/si p1.6/int6/so p1.7/int7/sck p10.0-p10.7/seg24-seg31 port 10 port 2 p2.0-p2.7/seg56-seg63 port 5 p5.0/seg80 p5.1/seg81 p5.2/seg82 p5.3/seg83 p5.4/seg84/int8 p5.5/seg85/int9 p5.6/seg86/int10 p5.7/seg87/int11 port 4 p4.0-p4.7/seg72-seg79 test main osc. sub osc. low voltage reset watch timer buz/int4/p1.4 av ref /int0/p1.0 port 3 p3.0-p3.7/seg64-seg71 port 9 p9.0-p9.7/seg32-seg39 port 8 p8.0-p8.7/seg40-seg47 port 7 p7.0-p7.7/seg48-seg55 p6.0-p6.2/cin1-cin2 port 6 figure 1-1. block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 4
pin assignment S3F82NB 128-qfp-1420 com9/seg1 com8/seg0 com7 com6 com5 com4 com3 com2 com1 com0 v lc4 v lc3 v lc2 v lc1 v lc0 p1.7/sck/int7 p1.6/so/int6 p1.5/si/int5 p1.4/buz/int4 v dd v ss x out x in test xt in xt out nreset p1.3/int3 p1.2/int2 p1.1/int1 p1.0/av ref /int0 p0.7/ad7 p0.6/ad6 p0.5/ad5 p0.4/ad4 p0.3/t0out/t0pwm/t0cap/ad3 p0.2/t1out/t1pwm/t1cap/ad2 p0.1/t0clk/ad1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 p10.4/seg28 p10.5/seg29 p10.6/seg30 p10.7/seg31 p9.0/seg32 p9.1/seg33 p9.2/seg34 p9.3/seg35 p9.4/seg36 p9.5/seg37 p9.6/seg38 p9.7/seg39 p8.0/seg40 p8.1/seg41 p8.2/seg42 p8.3/seg43 p8.4/seg44 p8.5/seg45 p8.6/seg46 p8.7/seg47 p7.0/seg48 p7.1/seg49 p7.2/seg50 p7.3/seg51 p7.4/seg52 p7.5/seg53 p7.6/seg54 p7.7/seg55 p2.0/seg56 p2.1/seg57 p2.2/seg58 p2.3/seg59 p2.4/seg60 p2.5/seg61 p2.6/seg62 p2.7/seg63 p3.0/seg64 p3.1/seg65 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 p0.0/t1clk/ad0 p6.2/cin2 p6.1/cin1 p6.0/cin0 p5.7/int11/seg87 p5.6/int10/seg86 p5.5/int9/seg85 p5.4/int8/seg84 p5.3/seg83 p5.2/seg82 p5.1/seg81 p5.0/seg80 p4.7/seg79 p4.6/seg78 p4.5/seg77 p4.4/seg76 p4.3/seg75 p4.2/seg74 p4.1/seg73 p4.0/seg72 p3.7/seg71 p3.6/seg70 p3.5/seg69 p3.4/seg68 p3.3/seg67 p3.2/seg66 com10/seg2 com11/seg3 com12/seg4 com13/seg5 com14/seg6 com15/seg7 seg8 seg9 seg10 seg11 seg12 seg13 seg14 seg15 seg16 seg17 seg18 seg19 seg20 seg21 seg22 seg23 p10.0/seg24 p10.1/seg25 p10.2/seg26 p10.3/seg27 figure 1-2. S3F82NB pin assignments (128-qfp-1420) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 5
pin descriptions table 1-1. S3F82NB pin descriptions pin names pin type pin description circuit type pin numbers share pins p0.0 p0.1 f-4 39 38 ad0/t1clk ad1/t0clk p0.2 p0.3 p0.4Cp0.7 i/o i/o port with 1-bit-programmable pins; input (p0.0 and p0.1: schmitt trigger input) or push-pull, open-drain output and software assignable pull-ups. f-3 37 36 35C32 ad2/t1out/ t1pwm/t1cap ad3/t0out/ t0pwm/t0cap ad4Cad7 p1.0 e-5 31 int0/ av ref p1.1 p1.2 p1.3 p1.4 p1.5 p1.6 p1.7 i/o i/o port with 1-bit-programmable pins; schmitt trigger input or push-pull, open- drain output and software assignable pull- ups. alternately used for external interrupt input (noise filters, interrupt enable and pending control). the p1.0 is configured as one of the p1.0/int0 and av ref by smart option. e-4 30 29 28 19 18 17 16 int1 int2 int3 int4/buz int5/si int6/so int7/sck p2.0Cp2.7 i/o i/o port with 1-bit-programmable pins; input or push-pull, open-drain output and software assignable pull-ups. h-8 74C67 seg56Cseg63 p3.0Cp3.7 i/o i/o port with 1-bit-programmable pins; input or push-pull, open-drain output and software assignable pull-ups. h-8 66C59 seg64Cseg71 p4.0Cp4.7 i/o i/o port with 1-bit-programmable pins; input or push-pull, open-drain output and software assignable pull-ups. h-8 58C51 seg72Cseg79 p5.0Cp5.3 i/o i/o port with 1-bit-programmable pins; input or push-pull, open-drain output and software assignable pull-ups. h-8 50C47 seg80Cseg83 p5.4Cp5.7 i/o i/o port with 1-bit-programmable pins; schmitt trigger input or push-pull, open- drain output and software assignable pull- ups. alternately used for external interrupt input (noise filters, interrupt enable and pending control). h-9 46C43 seg84Cseg87 int8Cint11 p6.0Cp6.1 h-26 42C41 cin0Ccin1 p6.2 i/o i/o port with 1-bit-programmable pins; schmitt trigger input or push-pull output and software assignable pull-ups. h-27 40 cin2 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 6
table 1-1. S3F82NB pin descriptions (continued) pin names pin type pin description circuit type pin numbers share pins p7.0Cp7.7 i/o i/o port with 4-bit-programmable pins; input or push-pull output and software assignable pull-ups. h-10 82C75 seg48Cseg55 p8.0Cp8.7 i/o i/o port with 4-bit-programmable pins; input or push-pull output and software assignable pull-ups. h-10 90C83 seg40Cseg47 p9.0Cp9.7 i/o i/o port with 4-bit-programmable pins; input or push-pull output and software assignable pull-ups. h-10 98C91 seg32Cseg39 p10.0Cp10.7 i/o i/o port with 4-bit-programmable pins; input or push-pull output and software assignable pull-ups. h-10 106C99 seg24Cseg31 com0Ccom7 com8Ccom15 o lcd common signal output. h-4 10C3 2C123 C seg0Cseg7 seg0Cseg7 seg8Cseg23 o h-4 2C123 122C107 com8Ccom15 C seg24Cseg31 seg32Cseg39 seg40Cseg47 seg48Cseg55 h-10 106C99 98C91 90C83 82C75 p10.0Cp10.7 p9.0Cp9.7 p8.0Cp8.7 p7.0Cp7.7 seg56Cseg63 seg64Cseg71 seg72Cseg79 seg80Cseg83 h-8 74C67 66C59 58C51 50C47 p2.0Cp2.7 p3.0Cp3.7 p4.0Cp4.7 p5.0Cp5.3 seg84Cseg87 i/o lcd segment signal output. h-9 46C43 p5.4Cp5.7/ int8Cint11 v lc0 C v lc4 C lcd power supply pins. C 15C11 C ad0 ad1 f-4 39 38 p0.0/t1clk p0.1/t0clk ad2 ad3 ad4Cad7 i/o a/d converter analog input channels. f-3 37 36 35C32 p0.2/t1out/ t1pwm/t1cap p0.3/t0out/ t0pwn/t0cap p0.4Cp0.7 av ref C a/d converter reference voltage. the av ref is configured as one of the p1.0/int0 and av ref by smart option. e-5 31 p1.0/int0 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 7
table 1-1. S3F82NB pin descriptions (continued) pin names pin type pin description circuit type pin numbers share pins cin0Ccin1 h-26 42C41 p6.0Cp6.1 cin2 i/o 3-channel comparator input cin0, cin1: comparator input only cin2: comparator input or external reference input. h-27 40 p6.2 sck i/o serial interface clock. e-4 16 p1.7/int7 so i/o serial interface data output. e-4 17 p1.6/int6 si i/o serial interface data input. e-4 18 p1.5/int5 buz i/o output pin for buzzer signal. e-4 19 p1.4/int4 t0out/t0pwm i/o timer 0 clock output and pwm output. f-3 36 p0.3/ad3/ t0cap t0cap i/o timer 0 capture input. f-3 36 p0.3/ad3/ t0out/t0pwm t0clk i/o timer 0 external clock input. f-4 38 p0.1/ad1 t1out/t1pwm i/o timer 1 clock output and pwm output. f-3 37 p0.2/ad2/ t1cap t1cap i/o timer 1 capture input. f-3 37 p0.2/ad2/ t1out/t1pwm t1clk i/o timer 1 external clock input. f-4 39 p0.0/ad0 int0 e-5 31 p1.0/av ref int1Cint3 int4 int5 int6 int7 e-4 30C28 19 18 17 16 p1.1Cp1.3 p1.4/buz p1.5/si p1.6/so p1.7/sck int8Cint11 i/o external interrupts input pins. the int0 is configured as one of the p1.0/int0 and av ref by smart option. h-9 46C43 p5.4Cp5.7/ seg84Cseg87 nreset i system reset pin b 27 C x in x out C main oscillator pins. C 23 22 C xt in xt out C crystal oscillator pins for sub clock. C 25 26 C test i test input: it must be connected to v ss C 24 C v dd C power supply input pins. C 20 C v ss C ground pins. C 21 C ps031601-0813 p r e l i m i n a r y S3F82NB product specification 8
pin circuits p-channel n-channel in v dd figure 1-3. pin circuit type a in v dd pull-up resistor schmitt trigger figure 1-4. pin circuit type b v dd p-channel n-channel data output disable figure 1-5. pin circuit type c ps031601-0813 p r e l i m i n a r y S3F82NB product specification 9
v dd output disable data pull-up resistor v dd i/o p-ch n-ch open drain enable resistor enable alternative function to adc data adcen adc select figure 1-6. pin circuit type f-3 (p0.2-p0.7) v dd output disable data pull-up resistor v dd i/o p-ch n-ch schmitt trigger open drain enable resistor enable figure 1-7. pin circuit type e-4 (p1 except p1.0) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 10
v dd output disable data pull-up resistor v dd i/o p-ch n-ch av ref open drain enable resistor enable mux smart option schmitt trigger figure 1-8. pin circuit type e-5 (p1.0) v dd output disable data pull-up resistor v dd i/o p-ch n-ch open drain enable resistor enable alternative function to adc data adcen adc select figure 1-9. pin circuit type f-4 (p0.0 C p0.1) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 11
out com/seg v lc1 v lc2 v lc3 output disable v lc0 v lc4 v ss figure 1-10. pin circuit type h-4 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 12
v dd open drain data seg output disable2 resistor enable v dd circuit type h-4 output disable1 i/o pull-up resistor p-ch n-ch figure 1-11. pin circuit type h-8 (p2Cp4, p5.0Cp5.3) v dd open drain data seg output disable2 resistor enable v dd circuit type h-4 output disable1 i/o pull-up resistor p-ch n-ch figure 1-12. pin circuit type h-9 (p5.4Cp5.7) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 13
v dd data seg output disable2 resistor enable v dd circuit type h-4 output disable1 i/o pull-up resistor p-ch n-ch figure 1-13. pin circuit type h-10 (p7Cp10) data pull-up enable v dd i/o output disable pull-up resistor circuit type c analog input sel digital in analog in figure 1-14. pin circuit type h-26 (p6.0Cp6.1) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 14
data resistor enable v dd i/o output disable pull-up resistor circuit type c analog input sel digital in analog in external ref sel external v ref in figure 1-15. pin circuit type h-27 (p6.2) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 15
2 address spaces overview the S3F82NB microcontroller has two types of address space: internal program memory (rom) internal register file a 16-bit address bus supports program memory operations. a separate 8-bit register bus carries addresses and data between the cpu and the register file. the S3F82NB has an internal 64-kbyte flash rom. the 256-byte physical register space is expanded into an addressable area of 320 bytes using addressing modes. a 176-byte lcd display register file is implemented. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 16
program memory (rom) program memory (rom) stores program codes or table data. the S3F82NB has 64k bytes internal flash program memory. the first 256 bytes of the rom (0hC0ffh) are reserved for interrupt vector addresses. unused locations in this address range can be used as normal program memory. if you use the vector address area to store a program code, be careful not to overwrite the vector addresses stored in these locations. the rom address at which a program execution starts after a reset is 0100h in the S3F82NB. the reset address of rom can be changed by a smart option only in the S3F82NB (full-flash device). refer to the chapter 18. embedded flash memory interface for more detail contents. (decimal) 65,535 255 (hex) ffffh 00h 0 64k-bytes internal program memory area available isp sector area interrupt vector area smart option 3ch 3fh ffh 8ffh figure 2-1. program memory address space ps031601-0813 p r e l i m i n a r y S3F82NB product specification 17
smart option isp reset vector change selection bit:(1) 0 = obp reset vector address 1 = normal vector (address 0100h) isp reset vector address selection bits:(2) 00 = 200h(isp area size: 256 byte) 01 = 300h(isp area size: 512 byte) 10 = 500h(isp area size: 1024 byte) 11 = 900h(isp area size: 2048 byte) not used isp protection size selection bits:(4)(5) 00 = 256 bytes 01 = 512 bytes 10 = 1024 bytes 11 = 2048 bytes isp protection enable/disable bit:(3) 0 = enable (not erasable by ldc) 1 = disable (erasable by ldc) rom address: 003eh .7 .6 .5 .4 .3 .2 .1 .0 msb lsb lvr enable/disable bit (criteria voltage: 2.0v) 0 = disable lvr 1 = enable lvr rom address: 003fh .7 .6 .5 .4 .3 .2 .1 .0 msb lsb rom address: 003ch .7 .6 .5 .4 .3 .2 .1 .0 msb lsb not used rom address: 003dh .7 .6 .5 .4 .3 .2 .1 .0 msb lsb not used notes: 1. by setting isp reset vector change selection bit (3e.7) to '0', user can have the available isp area. if isp reset vector change selection bit (3eh.7) is '1', 3eh.6 and 3eh.5 are meaningless. 2. if isp reset vector change selection bit (3eh.7) is '0', user must change isp reset vector address from 0100h to some address which user want to set reset address (0200h, 0300h, 0500h or 0900h). if the reset vector address is 0200h, the isp area can be assigned from 0100h to 01ffh (256bytes). if 0300h, the isp area can be assigned from 0100h to 02ffh (512bytes). if 0500h, the isp area can be assigned from 0100h to 04ffh (1024bytes). if 0900h, the isp area can be assigned from 0100h to 08ffh (2048bytes). 3. if isp protection enable/disable bit is '0', user can't erase or program the isp area selected by 3eh.1 and 3eh.0 in flash memory. 4. user can select suitable isp protection size by 3eh.1 and 3eh.0. if isp protection enable/disable bit (3eh.2) is '1', 3eh.1 and 3eh.0 are meaningless. 5. after selecting isp reset vector address in selecting isp protection size, don't select upper than isp area size. these bits should be always logic "111111b". av ref or p1.0/int0 selection bit: 0 = av ref 1 = p1.0/int0 fi g ure 2-2. smart o p tion ps031601-0813 p r e l i m i n a r y S3F82NB product specification 18
smart option is the rom option for start condition of the chip. the rom address used by smart option is from 003ch to 003fh. the S3F82NB only use 003eh to 003fh. when any values are written in the smart option area (003ch-003fh) by ldc instruction, the data of the area may be changed but the smart option is not affected. the data for smart option should be written in the smart option area (003ch-003fh) by otp/mtp programmer (writer tools). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 19
register architecture in the S3F82NB implementation, the upper 64-byte area of register files is expanded two 64-byte areas, called set 1 and set 2 . the upper 32-byte area of set 1 is further expanded two 32-byte register banks (bank 0 and bank 1), and the lower 32-byte area is a single 32-byte common area. in case of S3F82NB the total number of addressable 8-bit registers is 4,193. of these 4,193 registers, 13 bytes are for cpu and system control registers, 68 bytes are for peripheral control and data registers, 16 bytes are used as a shared working registers, and 4,096 registers are for general-purpose use, page 0-page15 (including 176 bytes for lcd display registers and 1 byte for peripheral control register). you can always address set 1 register locations, regardless of which of the ten register pages is currently selected. set 1 locations, however, can only be addressed using register addressing modes. the extension of register space into separately addressable areas (sets, banks, and pages) is supported by various addressing mode restrictions, the select bank instructions, sb0 and sb1, and the register page pointer (pp). specific register types and the area (in bytes) that they occupy in the register file are summarized in table 2-1. table 2-1. S3F82NB register type summary register type number of bytes general-purpose registers (including the 16-byte common working register area, sixteen 192-byte prime register area (including lcd data registers and peripheral control register), and sixteen 64-byte set 2 area) cpu and system control registers mapped clock, peripheral, i/o control, and data registers 4,112 13 68 total addressable bytes 4,193 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 20
system registers (register addressing mode) general purpose register (register addressing mode) bank 1 system and peripheral control registers bank 0 system and peripheral control registers (register addressing mode) set1 ffh 32 bytes e0h dfh d0h cfh c0h prime data registers (all addressing modes) lcd display reigster 176 bytes 64 bytes peripheral control register (all addressing modes) page 15 00h b0h 1 byte afh page 15 page 14 page 13 page 3 page 2 ~ ~ c0h bfh 00h ffh 192 bytes ~ page 1 page 1 ~ ffh ffh ffh page 0 prime data registers (all addressing modes) page 0 set 2 general-purpose data registers (indirect register, indexed mode, and stack operations) ffh ffh ffh ~ ~ ~ ~ ~ ~ ~ 256 bytes figure 2-3. internal register file organization (S3F82NB) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 21
register page pointer (pp) the s3c8-series architecture supports the logical expansion of the physical 256-byte internal register file (using an 8-bit data bus) into as many as 16 separately addressable register pages. page addressing is controlled by the register page pointer (pp, dfh). in the S3F82NB microcontroller, a paged register file expansion is implemented for lcd data registers, and the register page pointer must be changed to address other pages. after a reset, the page pointer's source value (lower nibble) and the destination value (upper nibble) are always "0000", automatically selecting page 0 as the source and destination page for register addressing. register page pointer (pp) dfh ,set 1, r/w lsb msb .7 .6 .5 .4 .3 .2 .1 .0 destination register page selection bits: 0000 destination: page 0 0001 destination: page 1 0010 destination: page 2 0011 destination: page 3 0100 destination: page 4 0101 destination: page 5 0110 destination: page 6 0111 destination: page 7 1000 destination: page 8 1001 destination: page 9 1010 destination: page 10 1011 destination: page 11 1100 destination: page 12 1101 destination: page 13 1110 destination: page 14 1111 destination: page 15 source register page selection bits: 0000 source: page 0 0001 source: page 1 0010 source: page 2 0011 source: page 3 0100 source: page 4 0101 source: page 5 0110 source: page 6 0111 source: page 7 1000 source: page 8 1001 source: page 9 1010 source: page 10 1011 source: page 11 1100 source: page 12 1101 source: page 13 1110 source: page 14 1111 source: page 15 notes: 1. in the S3F82NB microcontroller, the internal register file is configured as sixteen pages (pages 0-15). 2. the page 0-14 are used for general purpose register file and page 15 is used for the lcd data register (00h-afh) and peripheral control regiser (b0h). figure 2-4. register page pointer (pp)  ps031601-0813 p r e l i m i n a r y S3F82NB product specification 22
 programming tip using the page pointer for ram clear (page 0, page 1) ld pp,#00h ; destination 0, source 0 srp #0c0h ld r0,#0ffh ; page 0 ram clear starts ramcl0 clr @r0 djnz r0,ramcl0 clr @r0 ; r0 = 00h ld pp,#10h ; destination 1, source 0 ld r0,#0ffh ; page 1 ram clear starts ramcl1 clr @r0 djnz r0,ramcl1 clr @r0 ; r0 = 00h note: you should refer to page 6-39 and use djnz instruction properly when djnz instruction is used in your program. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 23
register set 1 the term set 1 refers to the upper 64 bytes of the register file, locations c0hCffh. the upper 32-byte area of this 64-byte space (e0hCffh) is expanded two 32-byte register banks, bank 0 and bank 1 . the set register bank instructions, sb0 or sb1, are used to address one bank or the other. a hardware reset operation always selects bank 0 addressing. the upper two 32-byte areas (bank 0 and bank 1) of set 1 (e0hCffh) contains 68 mapped system and peripheral control registers. the lower 32-byte area contains 16 system registers (d0hCdfh) and a 16-byte common working register area (c0hCcfh). you can use the common working register area as a scratch area for data operations being performed in other areas of the register file. registers in set 1 location are directly accessible at all times using register addressing mode. the 16-byte working register area can only be accessed using working register addressing (for more information about working register addressing, please refer to chapter 3, addressing modes.) register set 2 the same 64-byte physical space that is used for set 1 location c0hCffh is logically duplicated to add another 64 bytes of register space. this expanded area of the register file is called set 2 . for the S3F82NB, the set 2 address range (c0hCffh) is accessible on pages 0-15. the logical division of set 1 and set 2 is maintained by means of addressing mode restrictions. you can use only register addressing mode to access set 1 location. in order to access registers in set 2, you must use register indirect addressing mode or indexed addressing mode. the set 2 register area of page 0 is commonly used for stack operations. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 24
prime register space the lower 192 bytes (00hCbfh) of the s3c82nb's sixteen 256-byte register pages is called prime register area. prime registers can be accessed using any of the seven addressing modes (see chapter 3, "addressing modes.") the prime register area on page 0 is immediately addressable following a reset. in order to address prime registers on pages 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 or 15 you must set the register page pointer (pp) to the appropriate source and destination values. page15 page 14 page 13 page 3 page 2 page 1 ffh fch e0h d0h c0h set 1 bank 0 peripheral and i/o general-purpose cpu and system control lcd data register ffh ffh ffh ffh c0h 00h bfh page 0 set 2 page 0 prime space 00h afh bank 1 ffh ffh ffh page15 b0h lcd data register area figure 2-5. set 1, set 2, prime area register, and lcd data register map ps031601-0813 p r e l i m i n a r y S3F82NB product specification 25
working registers instructions can access specific 8-bit registers or 16-bit register pairs using either 4-bit or 8-bit address fields. when 4-bit working register addressing is used, the 256-byte register file can be seen by the programmer as one that consists of 32 8-byte register groups or "slices." each slice comprises of eight 8-bit registers. using the two 8-bit register pointers, rp1 and rp0, two working register slices can be selected at any one time to form a 16-byte working register block. using the register pointers, you can move this 16-byte register block anywhere in the addressable register file, except the set 2 area. the terms slice and block are used in this manual to help you visualize the size and relative locations of selected working register spaces: one working register slice is 8 bytes (eight 8-bit working registers, r0Cr7 or r8Cr15) one working register block is 16 bytes (sixteen 8-bit working registers, r0Cr15) all the registers in an 8-byte working register slice have the same binary value for their five most significant address bits. this makes it possible for each register pointer to point to one of the 24 slices in the register file. the base addresses for the two selected 8-byte register slices are contained in register pointers rp0 and rp1. after a reset, rp0 and rp1 always point to the 16-byte common area in set 1 (c0hCcfh). each register pointer points to one 8-byte slice of the register space, selecting a total 16-byte working register block. 1 1 1 1 1 x x x rp1 (registers r8-r15) rp0 (registers r0-r7) slice 32 slice 31 ~ ~ cfh c0h ffh f8h f7h f0h fh 8h 7h 0h slice 2 slice 1 10h set 1 only 0 0 0 0 0 x x x figure 2-6. 8-byte working register areas (slices) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 26
using the register points register pointers rp0 and rp1, mapped to addresses d6h and d7h in set 1, are used to select two movable 8-byte working register slices in the register file. after a reset, they point to the working register common area: rp0 points to addresses c0hCc7h, and rp1 points to addresses c8hCcfh. to change a register pointer value, you load a new value to rp0 and/or rp1 using an srp or ld instruction. (see figures 2-7 and 2-8). with working register addressing, you can only access those two 8-bit slices of the register file that are currently pointed to by rp0 and rp1. you cannot, however, use the register pointers to select a working register space in set 2, c0hCffh, because these locations can be accessed only using the indirect register or indexed addressing modes. the selected 16-byte working register block usually consists of two contiguous 8-byte slices. as a general programming guideline, it is recommended that rp0 point to the "lower" slice and rp1 point to the "upper" slice (see figure 2-7). in some cases, it may be necessary to define working register areas in different (non- contiguous) areas of the register file. in figure 2-8, rp0 points to the "upper" slice and rp1 to the "lower" slice. because a register pointer can point to either of the two 8-byte slices in the working register block, you can flexibly define the working register area to support program requirements.  programming tip setting the register pointers srp #70h ; rp0 70h, rp1 78h srp1 #48h ; rp0 no change, rp1 48h, srp0 #0a0h ; rp0 a0h, rp1 no change clr rp0 ; rp0 00h, rp1 no change ld rp1,#0f8h ; rp0 no change, rp1 0f8h fh (r15) 0h (r0) 16-byte contiguous working register block register file contains 32 8-byte slices rp0 rp1 8h 7h 0 0 0 0 1 x x x 0 0 0 0 0 x x x 8-byte slice 8-byte slice figure 2-7. contiguous 16-byte working register block ps031601-0813 p r e l i m i n a r y S3F82NB product specification 27
16-byte contiguous working register block register file contains 32 8-byte slices 0 0 0 0 0 x x x rp1 1 1 1 1 0 x x x rp0 0h (r0) 7h (r15) f0h (r0) f7h (r7) 8-byte slice 8-byte slice figure 2-8. non-contiguous 16-byte working register block  programming tip using the rps to calculate the sum of a series of registers calculate the sum of registers 80hC85h using the register pointer. the register addresses from 80h through 85h contain the values 10h, 11h, 12h, 13h, 14h, and 15h, respectively: srp0 #80h ; rp0 80h add r0,r1 ; r0 r0 + r1 adc r0,r2 ; r0 r0 + r2 + c adc r0,r3 ; r0 r0 + r3 + c adc r0,r4 ; r0 r0 + r4 + c adc r0,r5 ; r0 r0 + r5 + c the sum of these six registers, 6fh, is located in the register r0 (80h). the instruction string used in this example takes 12 bytes of instruction code and its execution time is 36 cycles. if the register pointer is not used to calculate the sum of these registers, the following instruction sequence would have to be used: add 80h,81h ; 80h (80h) + (81h) adc 80h,82h ; 80h (80h) + (82h) + c adc 80h,83h ; 80h (80h) + (83h) + c adc 80h,84h ; 80h (80h) + (84h) + c adc 80h,85h ; 80h (80h) + (85h) + c now, the sum of the six registers is also located in register 80h. however, this instruction string takes 15 bytes of instruction code rather than 12 bytes, and its execution time is 50 cycles rather than 36 cycles. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 28
register addressing the s3c8-series register architecture provides an efficient method of working register addressing that takes full advantage of shorter instruction formats to reduce execution time. with register (r) addressing mode, in which the operand value is the content of a specific register or register pair, you can access any location in the register file except for set 2. with working register addressing, you use a register pointer to specify an 8-byte working register space in the register file and an 8-bit register within that space. registers are addressed either as a single 8-bit register or as a paired 16-bit register space. in a 16-bit register pair, the address of the first 8-bit register is always an even number and the address of the next register is always an odd number. the most significant byte of the 16-bit data is always stored in the even-numbered register, and the least significant byte is always stored in the next (+1) odd-numbered register. working register addressing differs from register addressing as it uses a register pointer to identify a specific 8-byte working register space in the internal register file and a specific 8-bit register within that space. msb rn lsb rn+1 n = even address figure 2-9. 16-bit register pair ps031601-0813 p r e l i m i n a r y S3F82NB product specification 29
rp1 rp0 register pointers 00h all addressing modes page 0 indirect register, indexed addressing modes page 0 register addressing only can be pointed by register pointer ffh e0h bfh control registers system registers special-purpose registers d0h c0h bank 1 bank 0 note: in the S3F82NB microcontroller, pages 0-15 are implemented. pages 0-15 contain all of the addressable registers in the internal register file. each register pointer (rp) can independently point to one of the 24 8-byte "slices" of the register file (other than set 2). after a reset, rp0 points to locations c0h-c7h and rp1 to locations c8h-cfh (that is, to the common working register area). ffh c0h set 2 prime registers cfh general-purpose register all addressing modes can be pointed to by register pointer lcd data registers peripheral control registers figure 2-10. register file addressing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 30
common working register area (c0hCcfh) after a reset, register pointers rp0 and rp1 automatically select two 8-byte register slices in set 1, locations c0hCcfh, as the active 16-byte working register block: rp0  c0hCc7h rp1  c8hCcfh this 16-byte address range is called common area . that is, locations in this area can be used as working registers by operations that address any location on any page in the register file. typically, these working registers serve as temporary buffers for data operations between different pages. page 15 ~ ffh fch e0h d0h c0h set 1 following a hardware reset, register pointers rp0 and rp1 point to the common working register area, locations c0h-cfh. rp0 = rp1 = 1 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 page 14 page 13 ffh ffh ffh c0h 00h peripheral control register area 00h afh ffh ffh ffh ~ page 3 page 2 page 1 ~ ~ ~ ~ ffh page 0 set 2 bfh page 0 prime space ~ page 15 lcd data register area b0h figure 2-11. common working register area ps031601-0813 p r e l i m i n a r y S3F82NB product specification 31
 programming tip addressing the common working register area as the following examples show, you should access working registers in the common area, locations c0hCcfh, using working register addressing mode only. examples 1. ld 0c2h,40h ; invalid addressing mode! use working register addressing instead: srp #0c0h ld r2,40h ; r2 (c2h) the value in location 40h 2. add 0c3h,#45h ; invalid addressing mode! use working register addressing instead: srp #0c0h add r3,#45h ; r3 (c3h) r3 + 45h 4-bit working register addressing each register pointer defines a movable 8-byte slice of working register space. the address information stored in a register pointer serves as an addressing "window" that makes it possible for instructions to access working registers very efficiently using short 4-bit addresses. when an instruction addresses a location in the selected working register area, the address bits are concatenated in the following way to form a complete 8-bit address: the high-order bit of the 4-bit address selects one of the register pointers ("0" selects rp0, "1" selects rp1). the five high-order bits in the register pointer select an 8-byte slice of the register space. the three low-order bits of the 4-bit address select one of the eight registers in the slice. as shown in figure 2-12, the result of this operation is that the five high-order bits from the register pointer are concatenated with the three low-order bits from the instruction address to form the complete address. as long as the address stored in the register pointer remains unchanged, the three bits from the address will always point to an address in the same 8-byte register slice. figure 2-13 shows a typical example of 4-bit working register addressing. the high-order bit of the instruction "inc r6" is "0", which selects rp0. the five high-order bits stored in rp0 (01110b) are concatenated with the three low-order bits of the instruction's 4-bit address (110b) to produce the register address 76h (01110110b). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 32
together they create an 8-bit register address register pointer provides five high-order bits address opcode selects rp0 or rp1 rp1 rp0 4-bit address provides three low-order bits figure 2-12. 4-bit working register addressing register address (76h) rp0 0 1 1 1 0 0 0 0 0 1 1 1 0 1 1 0 r6 0 1 1 0 1 1 1 0 selects rp0 instruction 'inc r6' opcode rp1 0 1 1 1 1 0 0 0 figure 2-13. 4-bit working register addressing example ps031601-0813 p r e l i m i n a r y S3F82NB product specification 33
8-bit working register addressing you can also use 8-bit working register addressing to access registers in a selected working register area. to initiate 8-bit working register addressing, the upper four bits of the instruction address must contain the value "1100b." this 4-bit value (1100b) indicates that the remaining four bits have the same effect as 4-bit working register addressing. as shown in figure 2-14, the lower nibble of the 8-bit address is concatenated in much the same way as for 4-bit addressing: bit 3 selects either rp0 or rp1, which then supplies the five high-order bits of the final address; the three low-order bits of the complete address are provided by the original instruction. figure 2-15 shows an example of 8-bit working register addressing. the four high-order bits of the instruction address (1100b) specify 8-bit working register addressing. bit 4 ("1") selects rp1 and the five high-order bits in rp1 (10101b) become the five high-order bits of the register address. the three low-order bits of the register address (011) are provided by the three low-order bits of the 8-bit instruction address. the five address bits from rp1 and the three address bits from the instruction are concatenated to form the complete register address, 0abh (10101011b). 8-bit logical address 8-bit physical address register pointer provides five high-order bits address selects rp0 or rp1 rp1 rp0 three low-order bits these address bits indicate 8-bit working register addressing 1100 figure 2-14. 8-bit working register addressing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 34
8-bit address form instruction 'ld r11, r2' rp0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 1 1 selects rp1 r11 register address (0abh) rp1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 specifies working register addressing figure 2-15. 8-bit working register addressing example ps031601-0813 p r e l i m i n a r y S3F82NB product specification 35
system and user stack the s3c8-series microcontrollers use the system stack for data storage, subroutine calls and returns. the push and pop instructions are used to control system stack operations. the S3F82NB architecture supports stack operations in the internal register file. stack operations return addresses for procedure calls, interrupts, and data are stored on the stack. the contents of the pc are saved to stack by a call instruction and restored by the ret instruction. when an interrupt occurs, the contents of the pc and the flags register are pushed to the stack. the iret instruction then pops these values back to their original locations. the stack address value is always decreased by one before a push operation and increased by one after a pop operation. the stack pointer (sp) always points to the stack frame stored on the top of the stack, as shown in figure 2-16. stack contents after a call instruction stack contents after an interrupt top of stack flags pch pcl pcl pch top of stack low address high address figure 2-16. stack operations user-defined stacks you can freely define stacks in the internal register file as data storage locations. the instructions pushui, pushud, popui, and popud support user-defined stack operations. stack pointers (spl, sph) register locations d8h and d9h contain the 16-bit stack pointer (sp) that is used for system stack operations. the most significant byte of the sp address, sp15Csp8, is stored in the sph register (d8h), and the least significant byte, sp7Csp0, is stored in the spl register (d9h). after a reset, the sp value is undetermined. because only internal memory space is implemented in the S3F82NB, the spl must be initialized to an 8-bit value in the range 00hCffh. the sph register is not needed and can be used as a general-purpose register, if necessary. when the spl register contains the only stack pointer value (that is, when it points to a system stack in the register file), you can use the sph register as a general-purpose data register. however, if an overflow or underflow condition occurs as a result of increasing or decreasing the stack address value in the spl register during normal stack operations, the value in the spl register will overflow (or underflow) to the sph register, overwriting any other data that is currently stored there. to avoid overwriting data in the sph register, you can initialize the spl value to "ffh" instead of "00h". ps031601-0813 p r e l i m i n a r y S3F82NB product specification 36
 programming tip standard stack operations using push and pop the following example shows you how to perform stack operations in the internal register file using push and pop instructions: ld spl,#0ffh ; spl ffh ; (normally, the spl is set to 0ffh by the initialization ; routine) ? ? ? push pp ; stack address 0feh pp push rp0 ; stack address 0fdh rp0 push rp1 ; stack address 0fch rp1 push r3 ; stack address 0fbh r3 ? ? ? pop r3 ; r3 stack address 0fbh pop rp1 ; rp1 stack address 0fch pop rp0 ; rp0 stack address 0fdh pop pp ; pp stack address 0feh ps031601-0813 p r e l i m i n a r y S3F82NB product specification 37
3 addressing modes overview instructions that are stored in program memory are fetched for execution using the program counter. instructions indicate the operation to be performed and the data to be operated on. addressing mode is the method used to determine the location of the data operand. the operands specified in sam88rc instructions may be condition codes, immediate data, or a location in the register file, program memory, or data memory. the s3c8-series instruction set supports seven explicit addressing modes. not all of these addressing modes are available for each instruction. the seven addressing modes and their symbols are: register (r) indirect register (ir) indexed (x) direct address (da) indirect address (ia) relative address (ra) immediate (im) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 38
register addressing mode (r) in register addressing mode (r), the operand value is the content of a specified register or register pair (see figure 3-1). working register addressing differs from register addressing in that it uses a register pointer to specify an 8-byte working register space in the register file and an 8-bit register within that space (see figure 3-2). dst value used in instruction execution opcode operand 8-bit register file address point to one register in register file one-operand instruction (example) sample instruction: dec cntr ; where cntr is the label of an 8-bit register address program memory register file figure 3-1. register addressing dst opcode 4-bit working register point to the working register (1 of 8) two-operand instruction (example) sample instruction: add r1, r2 ; where r1 and r2 are registers in the currently selected working register area. program memory register file src 3 lsbs rp0 or rp1 selected rp points to start of working register block operand msb point to rp0 ot rp1 figure 3-2. working register addressing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 39
indirect register addressing mode (ir) in indirect register (ir) addressing mode, the content of the specified register or register pair is the address of the operand. depending on the instruction used, the actual address may point to a register in the register file, to program memory (rom), or to an external memory space (see figures 3-3 through 3-6). you can use any 8-bit register to indirectly address another register. any 16-bit register pair can be used to indirectly address another memory location. please note, however, that you cannot access locations c0hCffh in set 1 using the indirect register addressing mode. dst address of operand used by instruction opcode address 8-bit register file address point to one register in register file one-operand instruction (example) sample instruction: rl @shift ; where shift is the label of an 8-bit register address program memory register file value used in instruction execution operand figure 3-3. indirect register addressing to register file ps031601-0813 p r e l i m i n a r y S3F82NB product specification 40
indirect register addressing mode (continued) dst opcode pair points to register pair example instruction references program memory sample instructions: call @rr2 jp @rr2 program memory register file value used in instruction operand register program memory 16-bit address points to program memory figure 3-4. indirect register addressing to program memory ps031601-0813 p r e l i m i n a r y S3F82NB product specification 41
indirect register addressing mode (continued) dst opcode address 4-bit working register address point to the working register (1 of 8) sample instruction: or r3, @r6 program memory register file src 3 lsbs value used in instruction operand selected rp points to start fo working register block rp0 or rp1 msb points to rp0 or rp1 ~~ ~~ figure 3-5. indirect working register addressing to register file ps031601-0813 p r e l i m i n a r y S3F82NB product specification 42
indirect register addressing mode (concluded) dst opcode 4-bit working register address sample instructions: lcd r5,@rr6 ; program memory access lde r3,@rr14 ; external data memory access lde @rr4, r8 ; external data memory access program memory register file src value used in instruction operand example instruction references either program memory or data memory program memory or data memory next 2-bit point to working register pair (1 of 4) lsb selects register pair 16-bit address points to program memory or data memory rp0 or rp1 msb points to rp0 or rp1 selected rp points to start of working register block figure 3-6. indirect working register addressing to program or data memory ps031601-0813 p r e l i m i n a r y S3F82NB product specification 43
indexed addressing mode (x) indexed (x) addressing mode adds an offset value to a base address during instruction execution in order to calculate the effective operand address (see figure 3-7). you can use indexed addressing mode to access locations in the internal register file or in external memory. please note, however, that you cannot access locations c0hCffh in set 1 using indexed addressing mode. in short offset indexed addressing mode, the 8-bit displacement is treated as a signed integer in the range C128 to +127. this applies to external memory accesses only (see figure 3-8.) for register file addressing, an 8-bit base address provided by the instruction is added to an 8-bit offset contained in a working register. for external memory accesses, the base address is stored in the working register pair designated in the instruction. the 8-bit or 16-bit offset given in the instruction is then added to that base address (see figure 3-9). the only instruction that supports indexed addressing mode for the internal register file is the load instruction (ld). the ldc and lde instructions support indexed addressing mode for internal program memory and for external data memory, when implemented. dst/src opcode two-operand instruction example point to one of the woking register (1 of 8) sample instruction: ld r0, #base[r1] ; where base is an 8-bit immediate value program memory register file x 3 lsbs value used in instruction operand index base address rp0 or rp1 selected rp points to start of working register block ~~ ~~ + figure 3-7. indexed addressing to register file ps031601-0813 p r e l i m i n a r y S3F82NB product specification 44
indexed addressing mode (continued) register file operand program memory or data memory point to working register pair (1 of 4) lsb selects 16-bit address added to offset rp0 or rp1 msb points to rp0 or rp1 selected rp points to start of working register block dst/src opcode program memory x offset 4-bit working register address sample instructions: ldc r4, #04h[rr2] ; the values in the program address (rr2 + 04h) are loaded into register r4. lde r4,#04h[rr2] ; identical operation to ldc example, except that external program memory is accessed. next 2 bits register pair value used in instruction 8-bits 16-bits 16-bits + ~~ figure 3-8. indexed addressing to program or data memory with short offset ps031601-0813 p r e l i m i n a r y S3F82NB product specification 45
indexed addressing mode (concluded) register file operand program memory or data memory point to working register pair lsb selects 16-bit address added to offset rp0 or rp1 msb points to rp0 or rp1 selected rp points to start of working register block sample instructions: ldc r4, #1000h[rr2] ; the values in the program address (rr2 + 1000h) are loaded into register r4. lde r4,#1000h[rr2] ; identical operation to ldc example, except that external program memory is accessed. next 2 bits register pair value used in instruction 8-bits 16-bits 16-bits dst/src opcode program memory src offset 4-bit working register address offset + ~~ figure 3-9. indexed addressing to program or data memory ps031601-0813 p r e l i m i n a r y S3F82NB product specification 46
direct address mode (da) in direct address (da) mode, the instruction provides the operand's 16-bit memory address. jump (jp) and call (call) instructions use this addressing mode to specify the 16-bit destination address that is loaded into the pc whenever a jp or call instruction is executed. the ldc and lde instructions can use direct address mode to specify the source or destination address for load operations to program memory (ldc) or to external data memory (lde), if implemented. sample instructions: ldc r5,1234h ; the values in the program address (1234h) are loaded into register r5. lde r5,1234h ; identical operation to ldc example, except that external program memory is accessed. dst/src opcode program memory "0" or "1" lower address byte lsb selects program memory or data memory: "0" = program memory "1" = data memory memory address used upper address byte program or data memory figure 3-10. direct addressing for load instructions ps031601-0813 p r e l i m i n a r y S3F82NB product specification 47
direct address mode (continued) opcode program memory lower address byte memory address used upper address byte sample instructions: jp c,job1 ; where job1 is a 16-bit immediate address call display ; where display is a 16-bit immediate address next opcode figure 3-11. direct addressing for call and jump instructions ps031601-0813 p r e l i m i n a r y S3F82NB product specification 48
indirect address mode (ia) in indirect address (ia) mode, the instruction specifies an address located in the lowest 256 bytes of the program memory. the selected pair of memory locations contains the actual address of the next instruction to be executed. only the call instruction can use the indirect address mode. because the indirect address mode assumes that the operand is located in the lowest 256 bytes of program memory, only an 8-bit address is supplied in the instruction; the upper bytes of the destination address are assumed to be all zeros. current instruction program memory locations 0-255 program memory opcode dst lower address byte upper address byte next instruction lsb must be zero sample instruction: call #40h ; the 16-bit value in program memory addresses 40h and 41h is the subroutine start address. figure 3-12. indirect addressing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 49
relative address mode (ra) in relative address (ra) mode, a twos-complement signed displacement between C 128 and + 127 is specified in the instruction. the displacement value is then added to the current pc value. the result is the address of the next instruction to be executed. before this addition occurs, the pc contains the address of the instruction immediately following the current instruction. several program control instructions use the relative address mode to perform conditional jumps. the instructions that support ra addressing are btjrf, btjrt, djnz, cpije, cpijne, and jr. opcode program memory displacement program memory address used sample instructions: jr ult,$+offset ; where offset is a value in the range +127 to -128 next opcode + signed displacement value current instruction current pc value figure 3-13. relative addressing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 50
immediate mode (im) in immediate (im) addressing mode, the operand value used in the instruction is the value supplied in the operand field itself. the operand may be one byte or one word in length, depending on the instruction used. immediate addressing mode is useful for loading constant values into registers. (the operand value is in the instruction) opcode sample instruction: ld r0,#0aah program memory operand figure 3-14. immediate addressing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 51
4 control registers overview in this chapter, detailed descriptions of the S3F82NB control registers are presented in an easy-to-read format. you can use this chapter as a quick-reference source when writing application programs. figure 4-1 illustrates the important features of the standard register description format. control register descriptions are arranged in alphabetical order according to register mnemonic. more detailed information about control registers is presented in the context of the specific peripheral hardware descriptions in part ii of this manual. data and counter registers are not described in detail in this reference chapter. more information about all of the registers used by a specific peripheral is presented in the corresponding peripheral descriptions in part ii of this manual. the locations and read/write characteristics of all mapped registers in the S3F82NB register file are listed in table 4-1. the hardware reset value for each mapped register is described in chapter 8, "reset and power- down." table 4-1. set 1 registers register name mnemonic decimal hex r/w location d0hCd2h is not mapped. basic timer control register btcon 211 d3h r/w system clock control register clkcon 212 d4h r/w system flags register flags 213 d5h r/w register pointer 0 rp0 214 d6h r/w register pointer 1 rp1 215 d7h r/w stack pointer (high byte) sph 216 d8h r/w stack pointer (low byte) spl 217 d9h r/w instruction pointer (high byte) iph 218 dah r/w instruction pointer (low byte) ipl 219 dbh r/w interrupt request register irq 220 dch r interrupt mask register imr 221 ddh r/w system mode register sym 222 deh r/w register page pointer pp 223 dfh r/w ps031601-0813 p r e l i m i n a r y S3F82NB product specification 52
table 4-2. set 1, bank 0 registers register name mnemonic decimal hex r/w port group 0 control register pg0con 208 d0h r/w port group 1 control register pg1con 209 d1h r/w port 6 control register p6con 210 d2h r/w a/d converter data register (high byte) addatah 224 e0h r a/d converter data register (low byte) addatal 225 e1h r a/d converter control register adcon 226 e2h r/w timer 0 counter register t0cnt 227 e3h r timer 0 data register t0data 228 e4h r/w timer 0 control register t0con 229 e5h r/w timer b counter register tbcnt 230 e6h r timer a counter register tacnt 231 e7h r timer b data register tbdata 232 e8h r/w timer a data register tadata 233 e9h r/w timer b control register tbcon 234 eah r/w timer 1/a control register tacon 235 ebh r/w timer interrupt pending register tintpnd 236 ech r/w timer interrupt control register tintcon 237 edh r/w watch timer control register wtcon 238 eeh r/w lcd control register lcon 239 efh r/w lcd mode register lmod 240 f0h r/w comparator control register cmpcon 241 f1h r/w comparator result register cmpreg 242 f2h r sio control register siocon 243 f3h r/w sio data register siodata 244 f4h r/w sio pre-scaler register siops 245 f5h r/w flash memory sector address register (high byte) fmsech 246 f6h r/w flash memory sector address register (low byte) fmsecl 247 f7h r/w flash memory user programming enable register fmusr 248 f8h r/w flash memory control register fmcon 249 f9h r/w oscillator control register osccon 250 fah r/w stop control register stpcon 251 fbh r/w location fch is not mapped. basic timer counter btcnt 253 fdh r location feh is not mapped. interrupt priority register ipr 255 ffh r/w ps031601-0813 p r e l i m i n a r y S3F82NB product specification 53
table 4-3. set 1, bank 1 registers register name mnemonic decimal hex r/w port 4 control register (high byte) p4conh 208 d0h r/w port 4 control register (low byte) p4conl 209 d1h r/w port 4 pull-up resistor enable register p4pur 210 d2h r/w port 0 control register (high byte) p0conh 224 e0h r/w port 0 control register (low byte) p0conl 225 e1h r/w port 0 pull-up resistor enable register p0pur 226 e2h r/w alternative function selection register afsel 227 e3h r/w port 1 control register (high byte) p1conh 228 e4h r/w port 1 control register (low byte) p1conl 229 e5h r/w port 1 pull-up resistor enable register p1pur 230 e6h r/w port 1 interrupt pending register p1pnd 231 e7h r/w port 1 interrupt control register (high byte) p1inth 232 e8h r/w port 1 interrupt control register (low byte) p1intl 233 e9h r/w port 2 control register (high byte) p2conh 234 eah r/w port 2 control register (low byte) p2conl 235 ebh r/w port 2 pull-up resistor enable register p2pur 236 ech r/w port 3 pull-up resistor enable register p3pur 237 edh r/w port 3 control register (high byte) p3conh 238 eeh r/w port 3 control register (low byte) p3conl 239 efh r/w port 0 data register p0 240 f0h r/w port 1 data register p1 241 f1h r/w port 2 data register p2 242 f2h r/w port 3 data register p3 243 f3h r/w port 4 data register p4 244 f4h r/w port 5 data register p5 245 f5h r/w port 6 data register p6 246 f6h r/w port 7 data register p7 247 f7h r/w port 8 data register p8 248 f8h r/w port 9 data register p9 249 f9h r/w port 10 data register p10 250 fah r/w port 5 interrupt control register p5int 251 fbh r/w port 5 interrupt pending register p5pnd 252 fch r/w port 5 pull-up resistor enable register p5pur 253 fdh r/w port 5 control register (high byte) p5conh 254 feh r/w port 5 control register (low byte) p5conl 255 ffh r/w ps031601-0813 p r e l i m i n a r y S3F82NB product specification 54
table 4-4. page 15 registers register name mnemonic decimal hex r/w reset source indicating register resetid 176 b0h r/w ps031601-0813 p r e l i m i n a r y S3F82NB product specification 55
flags - system flags register .7 carry flag (c) .6 zero flag (z) .5 bit identifier reset value read/write bit addressing mode r = read-only w = write-only r/w = read/write '-' = not used type of addressing that must be used to address the bit (1-bit, 4-bit, or 8-bit) reset value notation: '-' = not used 'x' = undetermined value '0' = logic zero '1' = logic one bit number(s) that is/are appended to the register name for bit addressing name of individual bit or related bits full register name register id sign flag (s) 0 operation does not generate a carry or borrow condition 0 operation generates carry-out or borrow into high-order bit 7 0 operation result is a non-zero value 0 operation result is zero 0 operation generates positive number (msb = "0") 0 operation generates negative number (msb = "1") description of the effect of specific bit settings set 1 register location in the internal register file d5h register address (hexadecimal) .7 .6 .5 xxx r/w r/w r/w register addressing mode only .4 .3 .2 .1 .0 x r/w x r/w x r/w x r/w 0 r/w bit number: msb = bit 7 lsb = bit 0 figure 4-1. register description format ps031601-0813 p r e l i m i n a r y S3F82NB product specification 56
adcon a/d converter control register e2h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value  0 0 0 0 0 0 0 read/write  r/w r/w r/w r r/w r/w r/w addressing mode register addressing mode only .7 not used for the S3F82NB .6C.4 a/d input pin selection bits 0 0 0 ad0 0 0 1 ad1 0 1 0 ad2 0 1 1 ad3 1 0 0 ad4 1 0 1 ad5 1 1 0 ad6 1 1 1 ad7 .3 end-of-conversion bit (read-only) 0 conversion not complete 1 conversion complete .2C.1 clock source selection bits 0 0 fxx/16 0 1 fxx/8 1 0 fxx/4 1 1 fxx/1 .0 start or enable bit 0 disable operation 1 start operation ps031601-0813 p r e l i m i n a r y S3F82NB product specification 57
afsel alternative function selection register e3h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value       0 0 read/write       r/w r/w addressing mode register addressing mode only .7C.2 not used for the S3F82NB .1 p0.3 alternative mode selection bit 0 alternative function (ad3) 1 alternative function (t0out/t0pwm) .0 p0.2 alternative mode selection bit 0 alternative function (ad2) 1 alternative function (t1out/t1pwm) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 58
btcon basic timer control register d3h set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.4 watchdog timer function disable code (for system reset) 1 0 1 0 disable watchdog timer function others enable watchdog timer function .3C.2 basic timer input clock selection bits (3) 0 0 fxx/4096 0 1 fxx/1024 1 0 fxx/128 1 1 fxx /16 .1 basic timer counter clear bit (1) 0 no effect 1 clear the basic timer counter value .0 clock frequency divider clear bit for basic timer and timer/counters (2) 0 no effect 1 clear both clock frequency dividers notes : 1. when you write a 1 to btcon.1, the basic timer counter value is cleared to "00h". immediately following the write operation, the btcon.1 value is automatically cleared to 0. 2. when you write a "1" to btcon.0, the corresponding frequency divider is cleared to "00h". immediately following the write operation, the btcon.0 value is automatically cleared to "0". 3. the fxx is selected clock for system (main osc. or sub osc.). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 59
clkcon system clock control register d4h set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0  0 0  read/write r/w  r/w r/w  addressing mode register addressing mode only .7 oscillator irq wake-up function bit 0 enable irq for main wake-up in power down mode 1 disable irq for main wake-up in power down mode .6C.5 not used for the S3F82NB .4C.3 cpu clock (system clock) selection bits (note) 0 0 fxx/16 0 1 fxx/8 1 0 fxx/2 1 1 fxx/1 .2C.0 not used for the S3F82NB note: after a reset, the slowest clock (divided by 16) is selected as the system clock. to select faster clock speeds, load the appropriate values to clkcon.3 and clkcon.4. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 60
cmpcon comparator control register f1h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 C 0 0 0 0 read/write r/w r/w r/w C r/w r/w r/w r/w addressing mode register addressing mode only .7 comparator enable bit 0 disable comparator 1 enable comparator .6 conversion time selection bit 0 8 x 2 5 /fx 1 8 x 2 4 /fx .5 external/internal reference selection bit 0 internal reference, cin0Ccin2; analog input 1 cin2; external reference, cin0Ccin1; analog input .4 not used, but you must keep 0 .3C.0 reference voltage selection bits selected v ref = v dd x (n+0.5)/16, n = 0 to 15 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 61
flags system flags register d5h set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value x x x x x x 0 0 read/write r/w r/w r/w r/w r/w r/w r r/w addressing mode register addressing mode only .7 carry flag (c) 0 operation does not generate a carry or borrow condition 1 operation generates a carry-out or borrow into high-order bit 7 .6 zero flag (z) 0 operation result is a non-zero value 1 operation result is zero .5 sign flag (s) 0 operation generates a positive number (msb = "0") 1 operation generates a negative number (msb = "1") .4 overflow flag (v) 0 operation result is  +127 or C128 1 operation result is > +127 or < C128 .3 decimal adjust flag (d) 0 add operation completed 1 subtraction operation completed .2 half-carry flag (h) 0 no carry-out of bit 3 or no borrow into bit 3 by addition or subtraction 1 addition generated carry-out of bit 3 or subtraction generated borrow into bit 3 .1 fast interrupt status flag (fis) 0 interrupt return (iret) in progress (when read) 1 fast interrupt service routine in progress (when read) .0 bank address selection flag (ba) 0 bank 0 is selected 1 bank 1 is selected ps031601-0813 p r e l i m i n a r y S3F82NB product specification 62
fmcon flash memory control register f9h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0  0 read/write r/w r/w r/w r/w r  r/w addressing mode register addressing mode only .7C.4 flash memory mode selection bits 0 1 0 1 programming mode 1 0 1 0 sector erase mode 0 1 1 0 hard lock mode others not available .3 sector erase status bit (read-only) 0 success sector erase 1 fail sector erase .2C.1 not used for the S3F82NB .0 flash operation start bit 0 operation stop bit 1 operation start bit note: the fmcon.0 will be cleared automatically just after the corresponding operation completed. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 63
fmsech flash memory sector address register (high byte) f6h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.0 flash memory sector address bits (high byte) the 15 th -8 th to select a sector of flash rom note: the high-byte flash memory sector address pointer value is higher eight bits of the 16-bit pointer address. fmsecl flash memory sector address register (low byte) f7h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 flash memory sector address bit (low byte) the 7 th bit to select a sector of flash rom .6C.0 dont care note: the low-byte flash memory sector address pointer value is lower eight bits of the 16-bit pointer address. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 64
fmusr flash memory user programming enable register f8h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.0 flash memory user programming enable bits 1 0 1 00101e nable user programming mode others disable user programming mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 65
imr interrupt mask register ddh set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value x x x x x x x x read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 interrupt level 7 (irq7) enable bit; external interrupts p5.4Cp5.7 0 disable (mask) 1 enable (unmask) .6 interrupt level 6 (irq6) enable bit; external interrupts p1.4Cp1.7 0 disable (mask) 1 enable (unmask) .5 interrupt level 5 (irq5) enable bit; external interrupts p1.0Cp1.3 0 disable (mask) 1 enable (unmask) .4 interrupt level 4 (irq4) enable bit; watch timer 0 disable (mask) 1 enable (unmask) .3 interrupt level 3 (irq3) enable bit; sio 0 disable (mask) 1 enable (unmask) .2 interrupt level 2 (irq2) enable bit; timer b match 0 disable (mask) 1 enable (unmask) .1 interrupt level 1 (irq1) enable bit; timer 1/a match/capture or overflow 0 disable (mask) 1 enable (unmask) .0 interrupt level 0 (irq0) enable bit; timer 0 match/capture or overflow 0 disable (mask) 1 enable (unmask) note: when an interrupt level is masked, any interrupt requests that may be issued are not recognized by the cpu. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 66
iph instruction pointer (high byte) dah set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value x x x x x x x x read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.0 instruction pointer address (high byte) the high-byte instruction pointer value is the upper eight bits of the 16-bit instruction pointer address (ip15Cip8). the lower byte of the ip address is located in the ipl register (dbh). ipl instruction pointer (low byte) dbh set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value x x x x x x x x read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.0 instruction pointer address (low byte) the low-byte instruction pointer value is the lower eight bits of the 16-bit instruction pointer address (ip7Cip0). the upper byte of the ip address is located in the iph register (dah). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 67
ipr interrupt priority register ffh set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value x x x x x x x x read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7, .4, and .1 priority control bits for interrupt groups a, b, and c 0 0 0 group priority undefined 0 0 1 b > c > a 0 1 0 a > b > c 0 1 1 b > a > c 1 0 0 c > a > b 1 0 1 c > b > a 1 1 0 a > c > b 1 1 1 group priority undefined .6 interrupt subgroup c priority control bit 0 irq6 > irq7 1 irq7 > irq6 .5 interrupt group c priority control bit 0 irq5 > (irq6, irq7) 1 (irq6, irq7) > irq5 .3 interrupt subgroup b priority control bit 0 irq3 > irq4 1 irq4 > irq3 .2 interrupt group b priority control bit 0 irq2 > (irq3, irq4) 1 (irq3, irq4) > irq2 .0 interrupt group a priority control bit 0 irq0 > irq1 1 irq1 > irq0 note: interrupt group a -irq0, irq1 interrupt group b -irq2, irq3, irq4 interrupt group c -irq5, irq6, irq7 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 68
irq interrupt request register dch set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r r r r r r r r addressing mode register addressing mode only .7 level 7 (irq7) request pending bit; external interrupts p5.4Cp5.7 0 not pending 1 pending .6 level 6 (irq6) request pending bit; external interrupts p1.4Cp1.7 0 not pending 1 pending .5 level 5 (irq5) request pending bit; external interrupts p1.0Cp1.3 0 not pending 1 pending .4 level 4 (irq4) request pending bit; watch timer 0 not pending 1 pending .3 level 3 (irq3) request pending bit; sio 0 not pending 1 pending .2 level 2 (irq2) request pending bit; timer b match 0 not pending 1 pending .1 level 1 (irq1) request pending bit; timer 1/a match/capture or overflow 0 not pending 1 pending .0 level 0 (irq0) request pending bit; timer 0 match/capture or overflow 0 not pending 1 pending ps031601-0813 p r e l i m i n a r y S3F82NB product specification 69
lcon lcd control register efh set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0  0 read/write r/w r/w r/w r/w r/w  r/w addressing mode register addressing mode only .7C.5 lcd clock selection bits 0 0 0 fw/2 7 (256 hz) 0 0 1 fw/2 6 (512 hz) 0 1 0 fw/2 5 (1024 hz) 0 1 1 fw/2 4 (2048 hz) 1 0 0 fw/2 3 (4096 hz) others not available .4 lcd bias selection bit 0 1/4 bias 1 1/5 bias .3 lcd duty selection bit 0 1/8 duty 1 1/16 duty .2C.1 not used for the S3F82NB .0 lcd display control bits 0 display off 1 display on notes: the clock and duty for lcd controller/driver is automatically initialized by hardware, whenever lcon register data value is re-write. so, the lcon register dont re-write frequently. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 70
lmod lcd mode control register f1h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0  read/write r/w r/w r/w r/w r/w  addressing mode register addressing mode only .7C.4 lcd contrast level control bits 0 0 0 0 1/16 step (the dimmest level) 0 0 0 1 2/16 step 0 0 1 0 3/16 step 0 0 1 1 4/16 step 0 1 0 0 5/16 step 0 1 0 1 6/16 step 0 1 1 0 7/16 step 0 1 1 1 8/16 step 1 0 0 0 9/16 step 1 0 0 1 10/16 step 1 0 1 0 11/16 step 1 0 1 1 12/16 step 1 1 0 0 13/16 step 1 1 0 1 14/16 step 1 1 1 0 15/16 step 1 1 1 1 16/16 step (the brightest level) .3 enable/disable lcd contrast control bit 0 disable lcd contrast control 1 enable lcd contrast control .2C.0 not used for the S3F82NB notes: v lcd = v dd x (n+17)/32, where n = 0 - 15. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 71
osccon oscillator control register fah set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value  0 0  0 read/write  r/w r/w  r/w addressing mode register addressing mode only .7C.4 not used for the S3F82NB .3 main oscillator control bit 0 main oscillator run 1 main oscillator stop .2 sub oscillator control bit 0 sub oscillator run 1 sub oscillator stop .1 not used for the S3F82NB .0 system clock selection bit 0 select main oscillator for system clock 1 select sub oscillator for system clock ps031601-0813 p r e l i m i n a r y S3F82NB product specification 72
p0conh port 0 control register (high byte) e0h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p0.7/ad7 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad7) .5C.4 p0.6/ad6 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad6) .3C.2 p0.5/ad5 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad5) .1C.0 p0.4/ad4 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad4) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 73
p0conl port 0 control register (low byte) e1h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p0.3/ad3/t0out/t0pwm/t0cap configuration bits 0 0 input mode (t0cap) 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad3 or t0out/t0pwm) .5C.4 p0.2/ad2/t1out/t1pwm/t1cap configuration bits 0 0 input mode (t1cap) 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad2 or t1out/t1pwm) .3C.2 p0.1/ad1/t0clk configuration bits 0 0 schmitt trigger input mode (t0clk) 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad1) .1C.0 p0.0/ad0/t1clk configuration bits 0 0 schmitt trigger input mode (t1clk) 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (ad0) notes: the p0.2 and p0.3 alternative functions depend on afsel.0 and afsel.1, respectively. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 74
p0pur port 0 pull-up resistor enable register e2h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 p0.7 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .6 p0.6 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .5 p0.5 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .4 p0.4 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .3 p0.3 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .2 p0.2 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .1 p0.1 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .0 p0.0 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable note: a pull-up resistor of port 0 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 75
p1conh port 1 control register (high byte) e4h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p1.7/int7/sck configuration bits 0 0 schmitt trigger input mode (sck) 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (sck out) .5C.4 p1.6/int6/so configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (so) .3C.2 p1.5/int5/si configuration bits 0 0 schmitt trigger input mode (si) 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 not available .1C.0 p1.4/int4/buz configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (buz) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 76
p1conl port 1 control register (low byte) e5h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p1.3/int3 configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 not available .5C.4 p1.2/int2 configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 not available .3C.2 p1.1/int1 configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 not available .1C.0 p1.0/int0/ av ref t configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 not available note: refer to the smart option for configuring as one of the p1.0/int0 and av ref . ps031601-0813 p r e l i m i n a r y S3F82NB product specification 77
p1pur port 1 pull-up resistor enable register e6h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 p1.7 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .6 p1.6 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .5 p1.5 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .4 p1.4 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .3 p1.3 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .2 p1.2 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .1 p1.1 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .0 p1.0 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable note: a pull-up resistor of port 1 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 78
p1inth port 1 interrupt control register (high byte) e8h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p1.7/external interrupt (int7) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .5C.4 p1.6/external interrupt (int6) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .3C.2 p1.5/external interrupt (int5) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .1C.0 p1.4/external interrupt (int4) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge ps031601-0813 p r e l i m i n a r y S3F82NB product specification 79
p1intl port 1 interrupt control register (low byte) e9h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p1.3/external interrupt (int3) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .5C.4 p1.2/external interrupt (int2) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .3C.2 p1.1/external interrupt (int1) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .1C.0 p1.0/external interrupt (int0) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge ps031601-0813 p r e l i m i n a r y S3F82NB product specification 80
p1pnd port 1 interrupt pending register e7h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 p1.7/external interrupt (int7) pending bit 0 clear pending bit (when write) 1 p1.7/int7 interrupt request is pending (when read) .6 p1.6/external interrupt (int6) pending bit 0 clear pending bit (when write) 1 p1.6/int6 interrupt request is pending (when read) .5 p1.5/external interrupt (int5) pending bit 0 clear pending bit (when write) 1 p1.5/int5 interrupt request is pending (when read) .4 p1.4/external interrupt (int4) pending bit 0 clear pending bit (when write) 1 p1.4/int4 interrupt request is pending (when read) .3 p1.3/external interrupt (int3) pending bit 0 clear pending bit (when write) 1 p1.3/int3 interrupt request is pending (when read) .2 p1.2/external interrupt (int2) pending bit 0 clear pending bit (when write) 1 p1.2/int2 interrupt request is pending (when read) .1 p1.1/external interrupt (int1) pending bit 0 clear pending bit (when write) 1 p1.1/int1 interrupt request is pending (when read) .0 p1.0/external interrupt (int0) pending bit 0 clear pending bit (when write) 1 p1.0/int0 interrupt request is pending (when read) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 81
p2conh port 2 control register (high byte) eah set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p2.7/seg63 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg63) .5-.4 p2.6/seg62 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg62) .3C.2 p2.5/seg61 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg61) .1C.0 p2.4/seg60 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg60) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 82
p2conl port 2 control register (low byte) ebh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p2.3/seg59 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg59) .5-.4 p2.2/seg58 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg58) .3C.2 p2.1/seg57 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg57) .1C.0 p2.0/seg56 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg56) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 83
p2pur port 2 pull-up resistor enable register ech set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 p2.7 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .6 p2.6 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .5 p2.5 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .4 p2.4 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .3 p2.3 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .2 p2.2 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .1 p2.1 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .0 p2.0 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable note: a pull-up resistor of port 2 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 84
p3conh port 3 control register (high byte) eeh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p3.7/seg71 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg71) .5C.4 p3.6/seg70 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg70) .3C.2 p3.5/seg69 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg69) .1C.0 p3.4/seg68 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg68) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 85
p3conl port 3 control register (low byte) efh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p3.3/seg67 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg67) .5C.4 p3.2/seg66 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg66) .3C.2 p3.1/seg65 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg65) .1C.0 p3.0/seg64 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg64) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 86
p3pur port 3 pull-up resistor enable register edh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 p3.7 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .6 p3.6 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .5 p3.5 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .4 p3.4 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .3 p3.3 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .2 p3.2 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .1 p3.1 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .0 p3.0 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable note: a pull-up resistor of port 3 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 87
p4conh port 4 control register (high byte) d0h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p4.7/seg79 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg79) .5C.4 p4.6/seg78 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg78) .3C.2 p4.5/seg77 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg77) .1C.0 p4.4/seg76 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg76) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 88
p4conl port 4 control register (low byte) d1h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p4.3/seg75 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg75) .5C.4 p4.2/seg74 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg74) .3C.2 p4.1/seg73 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg73) .1C.0 p4.0/seg72 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg72) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 89
p4pur port 4 pull-up resistor enable register d2h set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 p4.7 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .6 p4.6 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .5 p4.5 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .4 p4.4 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .3 p4.3 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .2 p4.2 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .1 p4.1 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .0 p4.0 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable note: a pull-up resistor of port 4 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 90
p5conh port 5 control register (high byte) feh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p5.7/seg87/int11 configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg87) .5C.4 p5.6/seg86/int10 configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg86) .3C.2 p5.5/seg85/int9 configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg85) .1C.0 p5.4/seg84/int8 configuration bits 0 0 schmitt trigger input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg84) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 91
p5conl port 5 control register (low byte) ffh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p5.3/seg83 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg83) .5C.4 p5.2/seg82 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg82) .3C.2 p5.1/seg81 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg81) .1C.0 p5.0/ seg80 configuration bits 0 0 input mode 0 1 output mode, open-drain 1 0 output mode, push-pull 1 1 alternative function (seg80) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 92
p5pur port 5 pull-up resistor enable register fdh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 p5.7 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .6 p5.6 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .5 p5.5 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .4 p5.4 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .3 p5.3 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .2 p5.2 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .1 p5.1 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable .0 p5.0 pull-up resistor enable bit 0 pull-up disable 1 pull-up enable note: a pull-up resistor of port 5 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 93
p5int port 5 interrupt control register fbh set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p5.7/external interrupt (int11) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .5C.4 p5.6/external interrupt (int10) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .3C.2 p5.5/external interrupt (int9) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge .1C.0 p5.4/external interrupt (int8) enable bits 0 0 disable interrupt 0 1 enable interrupt by falling edge 1 0 enable interrupt by rising edge 1 1 enable interrupt by both falling and rising edge ps031601-0813 p r e l i m i n a r y S3F82NB product specification 94
p5pnd port 5 interrupt pending register fch set 1, bank 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0  read/write r/w r/w r/w r/w  addressing mode register addressing mode only .7 p5.7/external interrupt (int11) pending bit 0 clear pending bit (when write) 1 p5.7/int11 interrupt request is pending (when read) .6 p5.6/external interrupt (int10) pending bit 0 clear pending bit (when write) 1 p5.6/int10 interrupt request is pending (when read) .5 p5.5/external interrupt (int9) pending bit 0 clear pending bit (when write) 1 p5.5/int9 interrupt request is pending (when read) .4 p5.4/external interrupt (int8) pending bit 0 clear pending bit (when write) 1 p5.4/int8 interrupt request is pending (when read) .3C.0 not used for the S3F82NB ps031601-0813 p r e l i m i n a r y S3F82NB product specification 95
p6con port 6 control register d2h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value  0 0 0 0 0 0 read/write  r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 not used for the S3F82NB .5C.4 p6.2/cin2 configuration bits 0 0 schmitt trigger input mode 0 1 schmitt trigger input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (cin2) .3C.2 p6.1/cin1 configuration bits 0 0 schmitt trigger input mode 0 1 schmitt trigger input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (cin1) .1C.0 p6.0/cin0 configuration bits 0 0 schmitt trigger input mode 0 1 schmitt trigger input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (cin0) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 96
pg0con port group 0 control register d0h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p10.4Cp10.7/seg28Cseg31 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg28 C seg31) .5C.4 p10.0Cp10.3/seg24Cseg27 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg24 C seg27) .3C.2 p9.4Cp9.7/seg36Cseg39 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg36 C seg39) .1C.0 p9.0Cp9.3/seg32Cseg35 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg32 C seg35) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 97
pg1con port group 1 control register d1h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.6 p8.4Cp8.7/seg44Cseg47 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg44 C seg47) .5C.4 p8.0Cp8.3/seg40Cseg43 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg40 C seg43) .3C.2 p7.4Cp7.7/seg52Cseg55 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg52 C seg55) .1C.0 p7.0Cp7.3/seg48Cseg51 configuration bits 0 0 input mode 0 1 input mode, pull-up 1 0 output mode, push-pull 1 1 alternative function (seg48 C seg51) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 98
pp register page pointer dfh set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.4 destination register page selection bits 0 0 0 0 destination: page 0 0 0 0 1 destination: page 1 0 0 1 0 destination: page 2 0 0 1 1 destination: page 3 0 1 0 0 destination: page 4 0 1 0 1 destination: page 5 0 1 1 0 destination: page 6 0 1 1 1 destination: page 7 1 0 0 0 destination: page 8 1 0 0 1 destination: page 9 1 0 1 0 destination: page 10 1 0 1 1 destination: page 11 1 1 0 0 destination: page 12 1 1 0 1 destination: page 13 1 1 1 0 destination: page 14 1 1 1 1 destination: page 15 .3 C .0 source register page selection bits 0 0 0 0 source: page 0 0 0 0 1 source: page 1 0 0 1 0 source: page 2 0 0 1 1 source: page 3 0 1 0 0 source: page 4 0 1 0 1 source: page 5 0 1 1 0 source: page 6 0 1 1 1 source: page 7 1 0 0 0 source: page 8 1 0 0 1 source: page 9 1 0 1 0 source: page 10 1 0 1 1 source: page 11 1 1 0 0 source: page 12 1 1 0 1 source: page 13 1 1 1 0 source: page 14 1 1 1 1 source: page 15 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 99
rp0 register pointer 0 d6h set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 1 1 0 0 0  read/write r/w r/w r/w r/w r/w  addressing mode register addressing only .7C.3 register pointer 0 address value register pointer 0 can independently point to one of the 256-byte working register areas in the register file. using the register pointers rp0 and rp1, you can select two 8-byte register slices at one time as active working register space. after a reset, rp0 points to address c0h in register set 1, selecting the 8-byte working register slice c0hCc7h. .2C.0 not used for the S3F82NB rp1 register pointer 1 d7h set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 1 1 0 0 1  read/write r/w r/w r/w r/w r/w  addressing mode register addressing only .7 C .3 register pointer 1 address value register pointer 1 can independently point to one of the 256-byte working register areas in the register file. using the register pointers rp0 and rp1, you can select two 8-byte register slices at one time as active working register space. after a reset, rp1 points to address c8h in register set 1, selecting the 8-byte working register slice c8hCcfh. .2 C .0 not used for the S3F82NB ps031601-0813 p r e l i m i n a r y S3F82NB product specification 100
resetid reset source indicating register b0h page 15 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 read/write  r/w  r/w r/w  addressing mode register addressing mode only .7C .5 not used for the S3F82NB .4 nreset pin indicating bit 0 reset is not generated by nreset pin (when read), cleared to 0(when write) 1 reset is generated by nreset pin (when read), no effect (when write) .3 not used for the S3F82NB .2 wdt reset indicating bit 0 reset is not generated by wdt (when read), cleared to 0(when write) 1 reset is generated by wdt (when read), no effect (when write) .1 lvr reset indicating bit 0 reset is not generated by lvr (when read), cleared to 0(when write) 1 reset is generated by lvr (when read), no effect (when write) .0 not used for the S3F82NB state of resetid depends on reset source .7 .6 .5 .4 .3 .2 .1 .0 lvr  0  0 1  wdt, nreset  note3  note3 note2  notes: 1. to clear an indicating register, write 0 to indicating flag bit. writing a 1 to a reset indicating flag (resetid.1C.2 an d .4) has no effect. 2. not effected by any other reset. 3. bits corresponding to sources that are active at the time of reset will be set. 4. the resetid.2C.1 are unknown values when a power-on reset occurs. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 101
siocon sio control register f3h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 sio shift clock selection bit 0 internal clock (p.s clock) 1 external clock (sck) .6 data direction control bit 0 msb-first mode 1 lsb-first mode .5 sio mode selection bit 0 receive-only mode 1 transmit/receive mode .4 shift clock edge selection bit 0 tx at falling edges, rx at rising edges 1 tx at rising edges, rx at falling edges .3 sio counter clear and shift start bit 0 no action 1 clear 3-bit counter and start shifting .2 sio shift operation enable bit 0 disable shifter and clock counter 1 enable shifter and clock counter .1 sio interrupt enable bit 0 disable sio interrupt 1 enable sio interrupt .0 sio interrupt pending bit 0 no interrupt pending (when read), clear pending condition (when write) 1 interrupt is pending ps031601-0813 p r e l i m i n a r y S3F82NB product specification 102
sph stack pointer (high byte) d8h set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value x x x x x x x x read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.0 stack pointer address (high byte) the high-byte stack pointer value is the upper eight bits of the 16-bit stack pointer address (sp15Csp8). the lower byte of the stack pointer value is located in register spl (d9h). the sp value is undefined following a reset. spl stack pointer (low byte) d9h set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value x x x x x x x x read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.0 stack pointer address (low byte) the low-byte stack pointer value is the lower eight bits of the 16-bit stack pointer address (sp7Csp0). the upper byte of the stack pointer value is located in register sph (d8h). the sp value is undefined following a reset. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 103
stpcon stop control register fbh set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.0 stop control bits 1 0 1 0 0 1 0 1 enable stop instruction other values disable stop instruction note: before execute the stop instruction. you must set this stpcon register as 10100101b. otherwise the stop instruction will not execute as well as reset will be generated. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 104
sym system mode register deh set 1 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0  x x x 0 0 read/write r/w  r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 not used, but you must keep 0 .6C.5 not used for the S3F82NB .4C.2 fast interrupt level selection bits (1) 0 0 0 irq0 0 0 1 irq1 0 1 0 irq2 0 1 1 irq3 1 0 0 irq4 1 0 1 irq5 1 1 0 irq6 1 1 1 irq7 .1 fast interrupt enable bit (2) 0 disable fast interrupt processing 1 enable fast interrupt processing .0 global interrupt enable bit (3) 0 disable all interrupt processing 1 enable all interrupt processing notes : 1. you can select only one interrupt level at a time for fast interrupt processing. 2. setting sym.1 to "1" enables fast interrupt processing for the interrupt level currently selected by sym.2Csym.4. 3. following a reset, you must enable global interrupt processing by executing an ei instruction (not by writing a "1" to sym.0). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 105
t0con timer 0 control register e5h set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0  read/write r/w r/w r/w r/w r/w r/w r/w  addressing mode register addressing mode only .7C.5 timer 0 input clock selection bits 0 0 0 fxx/1024 0 0 1 fxx/256 0 1 0 fxx/64 0 1 1 fxx/8 1 0 0 fxx/1 1 0 1 external clock (t0clk) falling edge 1 1 0 external clock (t0clk) rising edge 1 1 1 not available .4C.3 timer 0 operating mode selection bits 0 0 interval mode (t0out) 0 1 capture mode (capture on rising edge, counter running, ovf can occur) 1 0 capture mode (capture on falling edge, counter running, ovf can occur) 1 1 pwm mode (ovf and match interrupt can occur) .2 timer 0 counter clear bit 0 no effect 1 clear the timer 0 counter (when write) .1 timer 0 counter operating enable bit 0 disable counting operation 1 enable counting operation .0 not used for the S3F82NB ps031601-0813 p r e l i m i n a r y S3F82NB product specification 106
tacon timer 1/a control register ebh set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.5 timer 1/a input clock selection bits 0 0 0 fxx/1024 0 0 1 fxx/256 0 1 0 fxx/64 0 1 1 fxx/8 1 0 0 fxx/1 1 0 1 external clock (t1clk) falling edge 1 1 0 external clock (t1clk) rising edge 1 1 1 not available .4C.3 timer 1/a operating mode selection bits 0 0 interval mode (t1out) 0 1 capture mode (capture on rising edge, counter running, ovf can occur) 1 0 capture mode (capture on falling edge, counter running, ovf can occur) 1 1 pwm mode (ovf and match interrupt can occur) .2 timer 1/a counter clear bit 0 no effect 1 clear the timer 1/a counter (when write) .1 timer 1/a match/capture interrupt enable bit 0 disable counting operation 1 enable counting operation .0 timer 1/a operating mode selection bit 0 two 8-bit timers mode (timer a/b) 1 one 16-bit timer mode (timer 1) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 107
tbcon timer b control register eah set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0  0 0  read/write r/w r/w r/w  r/w r/w  addressing mode register addressing mode only .7C.5 timer b input clock selection bits 0 0 0 fxx/1024 0 0 1 fxx/256 0 1 0 fxx/64 0 1 1 fxx/8 1 0 0 fxx/1 others not available .4C.3 not used for the S3F82NB .2 timer b counter clear bit 0 no effect 1 clear the timer b counter (when write) .1 timer b counter operating enable bit 0 disable counting operation 1 enable counting operation .0 not used for the S3F82NB ps031601-0813 p r e l i m i n a r y S3F82NB product specification 108
tintcon timer interrupt control register edh set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value  0 0 0 0 0 read/write  r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.5 not used for the S3F82NB .4 timer b interrupt enable bit 0 disable interrupt 1 enable interrupt .3 timer 1/a match/capture interrupt enable bit 0 disable interrupt 1 enable interrupt .2 timer 1/a overflow interrupt enable bit 0 disable interrupt 1 enable interrupt .1 timer 0 match/capture interrupt enable bit 0 disable interrupt 1 enable interrupt .0 timer 0 overflow interrupt enable bit 0 disable interrupt 1 enable interrupt ps031601-0813 p r e l i m i n a r y S3F82NB product specification 109
tintpnd timer interrupt pending register ech set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value  0 0 0 0 0 read/write  r/w r/w r/w r/w r/w addressing mode register addressing mode only .7C.5 not used for the S3F82NB .4 timer b interrupt pending bit 0 no interrupt pending (when read), clear pending bit (when write) 1 interrupt is pending (when read) .3 timer 1/a match/capture interrupt pending bit 0 no interrupt pending (when read), clear pending bit (when write) 1 interrupt is pending (when read) .2 timer 1/a overflow interrupt pending bit 0 no interrupt pending (when read), clear pending bit (when write) 1 interrupt is pending (when read) .1 timer 0 match/capture interrupt pending bit 0 no interrupt pending (when read), clear pending bit (when write) 1 interrupt is pending (when read) .0 timer 0 overflow interrupt pending bit 0 no interrupt pending (when read), clear pending bit (when write) 1 interrupt is pending (when read) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 110
wtcon watch timer control register eeh set 1, bank 0 bit identifier .7 .6 .5 .4 .3 .2 .1 .0 reset value 0 0 0 0 0 0 0 0 read/write r/w r/w r/w r/w r/w r/w r/w r/w addressing mode register addressing mode only .7 watch timer clock selection bit 0 main system clock divided by 2 7 (fxx/128) 1 sub system clock (fxt) .6 watch timer interrupt enable bit 0 disable watch timer interrupt 1 enable watch timer interrupt .5C.4 buzzer signal selection bits 0 0 0.5 khz 0 1 1 khz 1 0 2 khz 1 1 4 khz .3C.2 watch timer speed selection bits 0 0 set watch timer interrupt to 0.5s 0 1 set watch timer interrupt to 0.25s 1 0 set watch timer interrupt to 0.125s 1 1 set watch timer interrupt to 3.91ms .1 watch timer enable bit 0 disable watch timer; clear frequency dividing circuits 1 enable watch timer .0 watch timer interrupt pending bit 0 no interrupt pending (when read), clear pending bit (when write) 1 interrupt is pending (when read) note: watch timer clock frequency (fw) is assumed to be 32.768 khz. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 111
5 interrupt structure overview the s3c8-series interrupt structure has three basic components: levels, vectors, and sources. the sam8 cpu recognizes up to eight interrupt levels and supports up to 128 interrupt vectors. when a specific interrupt level has more than one vector address, the vector priorities are established in hardware. a vector address can be assigned to one or more sources. levels interrupt levels are the main unit for interrupt priority assignment and recognition. all peripherals and i/o blocks can issue interrupt requests. in other words, peripheral and i/o operations are interrupt-driven. there are eight possible interrupt levels: irq0Cirq7, also called level 0Clevel 7. each interrupt level directly corresponds to an interrupt request number (irqn). the total number of interrupt levels used in the interrupt structure varies from device to device. the S3F82NB interrupt structure recognizes eight interrupt levels. the interrupt level numbers 0 through 7 do not necessarily indicate the relative priority of the levels. they are just identifiers for the interrupt levels that are recognized by the cpu. the relative priority of different interrupt levels is determined by settings in the interrupt priority register, ipr. interrupt group and subgroup logic controlled by ipr settings lets you define more complex priority relationships between different levels. vectors each interrupt level can have one or more interrupt vectors, or it may have no vector address assigned at all. the maximum number of vectors that can be supported for a given level is 128 (the actual number of vectors used for s3c8-series devices is always much smaller). if an interrupt level has more than one vector address, the vector priorities are set in hardware. S3F82NB uses nineteen vectors. sources a source is any peripheral that generates an interrupt. a source can be an external pin or a counter overflow. each vector can have several interrupt sources. in the S3F82NB interrupt structure, there are nineteen possible interrupt sources. when a service routine starts, the respective pending bit should be either cleared automatically by hardware or cleared "manually" by program software. the characteristics of the source's pending mechanism determine which method would be used to clear its respective pending bit. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 112
interrupt types the three components of the s3c8 interrupt structure described before levels, vectors, and sources are combined to determine the interrupt structure of an individual device and to make full use of its available interrupt logic. there are three possible combinations of interrupt structure components, called interrupt types 1, 2, and 3. the types differ in the number of vectors and interrupt sources assigned to each level (see figure 5-1): type 1: one level (irqn) + one vector (v 1 ) + one source (s 1 ) type 2: one level (irqn) + one vector (v 1 ) + multiple sources (s 1 C s n ) type 3: one level (irqn) + multiple vectors (v 1 C v n ) + multiple sources (s 1 C s n , s n+1 C s n+m ) in the S3F82NB microcontroller, two interrupt types are implemented. vectors sources levels s 1 v 1 s 2 type 2: irqn s 3 s n v 1 s 1 v 2 s 2 type 3: irqn v 3 s 3 v 1 s 1 type 1: irqn v n s n + 1 s n s n + 2 s n + m notes: 1. the number of s n and v n value is expandable. 2. in the S3F82NB implementation, interrupt types 1 and 3 are used. figure 5-1. s3c8-series interrupt types ps031601-0813 p r e l i m i n a r y S3F82NB product specification 113
S3F82NB interrupt structure the S3F82NB microcontroller supports nineteen interrupt sources. all nineteen of the interrupt sources have a corresponding interrupt vector address. eight interrupt levels are recognized by the cpu in this device-specific interrupt structure, as shown in figure 5-2. when multiple interrupt levels are active, the interrupt priority register (ipr) determines the order in which contending interrupts are to be serviced. if multiple interrupts occur within the same interrupt level, the interrupt with the lowest vector address is usually processed first (the relative priorities of multiple interrupts within a single level are fixed in hardware). when the cpu grants an interrupt request, interrupt processing starts. all other interrupts are disabled and the program counter value and status flags are pushed to stack. the starting address of the service routine is fetched from the appropriate vector address (plus the next 8-bit value to concatenate the full 16-bit address) and the service routine is executed. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 114
notes: 1. within a given interrupt level, the low vector address has high priority. for example, dah has higher priority than dch within the level irq0 the priorities within each level are set at the factory. 2. external interrupts are triggered by a rising or falling edge, depending on the corresponding control register setting. vectors sources levels reset/clear h/w 100h nreset basic timer overflow s/w dah timer 0 match/capture h/w, s/w e0h timer 1/a overflow s/w deh timer 1/a match/capture h/w, s/w dch timer 0 overflow s/w eeh p1.3 external interrupt s/w ech p1.2 external interrupt s/w eah p1.1 external interrupt s/w e8h p1.0 external interrupt irq0 irq1 irq5 s/w e2h irq2 timer b match s/w e4h irq3 sio interrupt s/w e6h irq4 watch timer overflow s/w f6h p1.7 external interrupt s/w f4h p1.6 external interrupt s/w f2h p1.5 external interrupt s/w f0h p1.4 external interrupt irq6 s/w feh p5.7 external interrupt s/w fch p5.6 external interrupt s/w fah p5.5 external interrupt s/w f8h p5.4 external interrupt irq7 figure 5-2. S3F82NB interrupt structure ps031601-0813 p r e l i m i n a r y S3F82NB product specification 115
interrupt vector addresses all interrupt vector addresses for the S3F82NB interrupt structure are stored in the vector address area of the internal 64-kbyte rom, 0hCffffh. (see figure 5-3). you can allocate unused locations in the vector address area as normal program memory. if you do so, please be careful not to overwrite any of the stored vector addresses (table 5-1 lists all vector addresses). the program reset address in the rom is 0100h. the reset address of rom can be changed by smart option in the S3F82NB (full-flash device). refer to the chapter 18. embedded flash memory interface for more detailed contents. (decimal) 65,535 255 (hex) ffffh 00h 0 64k-bytes internal program memory area available isp sector area interrupt vector area smart option 3ch 3fh ffh 8ffh figure 5-3. rom vector address area ps031601-0813 p r e l i m i n a r y S3F82NB product specification 116
table 5-1. interrupt vectors vector address interrupt source request reset/clear decimal value hex value interrupt level priority in level h/w s/w 256 100h basic timer overflow reset C
218 dah timer 0 match/capture irq0 0
220 dch timer 0 overflow 1
222 deh timer 1/a match/capture irq1 0
224 e0h timer 1/a overflow 1
226 e2h timer b match irq2 C
228 e4h sio interrupt irq3 C
230 e6h watch timer overflow irq4 C
232 e8h p1.0 external interrupt irq5 0
234 eah p1.1 external interrupt 1
236 ech p1.2 external interrupt 2
238 eeh p1.3 external interrupt 3
240 f0h p1.4 external interrupt irq6 0
242 f2h p1.5 external interrupt 1
244 f4h p1.6 external interrupt 2
246 f6h p1.7 external interrupt 3
248 f8h p5.4 external interrupt irq7 0
250 fah p5.5 external interrupt 1
252 fch p5.6 external interrupt 2
254 feh p5.7 external interrupt 3
notes: 1. interrupt priorities are identified in inverse order: "0" is the highest priority, "1" is the next highest, and so on. 2. if two or more interrupts within the same level contend, the interrupt with the lowest vector address usually has priority o ver one with a higher vector address. the priorities within a given level are fixed in hardware. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 117
enable/disable interrupt instructions (ei, di) executing the enable interrupts (ei) instruction globally enables the interrupt structure. all interrupts are then serviced as they occur according to the established priorities. note the system initialization routine executed after a reset must always contain an ei instruction to globally enable the interrupt structure. during the normal operation, you can execute the di (disable interrupt) instruction at any time to globally disable interrupt processing. the ei and di instructions change the value of bit 0 in the sym register. system-level interrupt control registers in addition to the control registers for specific interrupt sources, four system-level registers control interrupt processing: the interrupt mask register, imr, enables (un-masks) or disables (masks) interrupt levels. the interrupt priority register, ipr, controls the relative priorities of interrupt levels. the interrupt request register, irq, contains interrupt pending flags for each interrupt level (as opposed to each interrupt source). the system mode register, sym, enables or disables global interrupt processing (sym settings also enable fast interrupts and control the activity of external interface, if implemented). table 5-2. interrupt control register overview control register id r/w function description interrupt mask register imr r/w bit settings in the imr register enable or disable interrupt processing for each of the eight interrupt levels: irq0Cirq7. interrupt priority register ipr r/w controls the relative processing priorities of the interrupt levels. the seven levels of S3F82NB are organized into three groups: a, b, and c. group a is irq0 and irq1, group b is irq2, irq3 and irq4, and group c is irq5, irq6, and irq7. interrupt request register irq r this register contains a request pending bit for each interrupt level. system mode register sym r/w this register enables/disables fast interrupt processing, dynamic global interrupt processing, and external interface control (an external memory interface is implemented in the S3F82NB microcontroller). note: before imr register is changed to any value, all interrupts must be disable. using di instruction is recommended. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 118
interrupt processing control points interrupt processing can therefore be controlled in two ways: globally or by specific interrupt level and source. the system-level control points in the interrupt structure are: global interrupt enable and disable (by ei and di instructions or by direct manipulation of sym.0) interrupt level enable/disable settings (imr register) interrupt level priority settings (ipr register) interrupt source enable/disable settings in the corresponding peripheral control registers note when writing an application program that handles interrupt processing, be sure to include the necessary register file address (register pointer) information. interrupt request register (read-only) irq0-irq7, interrupts interrupt mask register polling cycle interrupt priority register global interrupt control (ei, di or sym.0 manipulation) s r q reset ei vector interrupt cycle figure 5-4. interrupt function diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 119
peripheral interrupt control registers for each interrupt source there is one or more corresponding peripheral control registers that let you control the interrupt generated by the related peripheral (see table 5-3). table 5-3. interrupt source control and data registers interrupt source interrupt level register(s) location(s) in set 1 timer 0 match/capture timer 0 overflow irq0 t0con t0cnt t0data e5h, bank 0 e3h, bank 0 e4h, bank 0 timer 1/a match/capture timer 1/a overflow irq1 tacon tacnt tadata ebh, bank 0 e7h, bank 0 e9h, bank 0 timer b match irq2 tbcon tbcnt tbdata eah, bank 0 e6h, bank 0 e8h, bank 0 sio interrupt irq3 siocon siodata siops f3h, bank 0 f4h, bank 0 f5h, bank 0 watch timer overflow irq4 wtcon eeh, bank 0 p1.0 external interrupt p1.1 external interrupt p1.2 external interrupt p1.3 external interrupt irq5 p1conll p1intl p1pnd e5h, bank 1 e9h, bank 1 e7h, bank 1 p1.4 external interrupt p1.5 external interrupt p1.6 external interrupt p1.7 external interrupt irq6 p1conh p1inth p1pnd e4h, bank 1 e8h, bank 1 e7h, bank 1 p5.4 external interrupt p5.5 external interrupt p5.6 external interrupt p5.7 external interrupt irq7 p5conh p5int p5pnd feh, bank 1 fbh, bank 1 fch, bank 1 note: if a interrupt is un-mask (enable interrupt level) in the imr register, the pending bit and enable bit of the interrupt should be written after a di instruction is executed. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 120
system mode register (sym) the system mode register, sym (set 1, deh), is used to globally enable and disable interrupt processing and to control fast interrupt processing (see figure 5-5). a reset clears sym.1 and sym.0 to "0". the 3-bit value for fast interrupt level selection, sym.4Csym.2, is undetermined. the instructions ei and di enable and disable global interrupt processing, respectively, by modifying the bit 0 value of the sym register. in order to enable interrupt processing an enable interrupt (ei) instruction must be included in the initialization routine, which follows a reset operation. although you can manipulate sym.0 directly to enable and disable interrupts during the normal operation, it is recommended to use the ei and di instructions for this purpose. system mode register (sym) deh, set 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb global interrupt enable bit: (3) 0 = disable all interrupts processing 1 = enable all interrupts processing fast interrupt enable bit: (2) 0 = disable fast interrupts processing 1 = enable fast interrupts processing fast interrupt level selection bits: (1) 0 0 0 = irq0 0 0 1 = irq1 0 1 0 = irq2 0 1 1 = irq3 1 0 0 = irq4 1 0 1 = irq5 1 1 0 = irq6 1 1 1 = irq7 not used for the S3F82NB notes: 1. you can select only one interrupt level at a time for fast interrupt processing. 2. setting sym.1 to "1" enables fast interrupt processing for the interrupt processing for the interrupt level currently selected by sym.2-sym.4. 3. following a reset, you must enable global interrupt processing by executing ei instruction (not by writing a "1" to sym.0) always logic "0" figure 5-5. system mode register (sym) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 121
interrupt mask register (imr) the interrupt mask register, imr (set 1, ddh) is used to enable or disable interrupt processing for individual interrupt levels. after a reset, all imr bit values are undetermined and must therefore be written to their required settings by the initialization routine. each imr bit corresponds to a specific interrupt level: bit 1 to irq1, bit 2 to irq2, and so on. when the imr bit of an interrupt level is cleared to "0", interrupt processing for that level is disabled (masked). when you set a level's imr bit to "1", interrupt processing for the level is enabled (not masked). the imr register is mapped to register location ddh in set 1. bit values can be read and written by instructions using the register addressing mode. interrupt mask register (imr) ddh, set 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb irq1 irq2 irq4 irq5 irq6 irq7 irq0 irq3 note: before imr register is changed to any value, all interrupts must be disable. using di instruction is recommended. interrupt level enable : 0 = disable (mask) interrupt level 1 = enable (un-mask) interrupt level figure 5-6. interrupt mask register (imr) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 122
interrupt priority register (ipr) the interrupt priority register, ipr (set 1, bank 0, ffh), is used to set the relative priorities of the interrupt levels in the microcontrollers interrupt structure. after a reset, all ipr bit values are undetermined and must therefore be written to their required settings by the initialization routine. when more than one interrupt sources are active, the source with the highest priority level is serviced first. if two sources belong to the same interrupt level, the source with the lower vector address usually has the priority (this priority is fixed in hardware). to support programming of the relative interrupt level priorities, they are organized into groups and subgroups by the interrupt logic. please note that these groups (and subgroups) are used only by ipr logic for the ipr register priority definitions (see figure 5-7): group a irq0, irq1 group b irq2, irq3, irq4 group c irq5, irq6, irq7 ipr group b ipr group c irq2 b1 irq4 b2 irq3 b22 b21 irq5 c1 irq7 c2 irq6 c22 c21 ipr group a irq1 a2 irq0 a1 figure 5-7. interrupt request priority groups as you can see in figure 5-8, ipr.7, ipr.4, and ipr.1 control the relative priority of interrupt groups a, b, and c. for example, the setting "001b" for these bits would select the group relationship b > c > a. the setting "101b" would select the relationship c > b > a. the functions of the other ipr bit settings are as follows: ipr.5 controls the relative priorities of group c interrupts. interrupt group c includes a subgroup that has an additional priority relationship among the interrupt levels 5, 6, and 7. ipr.6 defines the subgroup c relationship. ipr.5 controls the interrupt group c. ipr.0 controls the relative priority setting of irq0 and irq1 interrupts. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 123
interrupt priority register (ipr) ffh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb group a: 0 = irq0 > irq1 1 = irq1 > irq0 subgroup b: 0 = irq3 > irq4 1 = irq4 > irq3 group c: 0 = irq5 > (irq6, irq7) 1 = (irq6, irq7) > irq5 subgroup c: 0 = irq6 > irq7 1 = irq7 > irq6 group b: 0 = irq2 > (irq3, irq4) 1 = (irq3, irq4) > irq2 group priority: 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 = undefined = b > c > a = a > b > c = b > a > c = c > a > b = c > b > a = a > c > b = undefined d7 d4 d1 figure 5-8. interrupt priority register (ipr) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 124
interrupt request register (irq) you can poll bit values in the interrupt request register, irq (set 1, dch), to monitor interrupt request status for all levels in the microcontrollers interrupt structure. each bit corresponds to the interrupt level of the same number: bit 0 to irq0, bit 1 to irq1, and so on. a "0" indicates that no interrupt request is currently being issued for that level. a "1" indicates that an interrupt request has been generated for that level. irq bit values are read-only addressable using register addressing mode. you can read (test) the contents of the irq register at any time using bit or byte addressing to determine the current interrupt request status of specific interrupt levels. after a reset, all irq status bits are cleared to 0. you can poll irq register values even if a di instruction has been executed (that is, if global interrupt processing is disabled). if an interrupt occurs while the interrupt structure is disabled, the cpu will not service it. you can, however, still detect the interrupt request by polling the irq register. in this way, you can determine which events occurred while the interrupt structure was globally disabled. interrupt request register (irq) dch, set 1, read-only .7 .6 .5 .4 .3 .2 .1 .0 msb lsb irq1 irq2 irq3 irq4 irq5 irq6 irq7 irq0 interrupt level request pending bits: 0 = interrupt level is not pending 1 = interrupt level is pending figure 5-9. interrupt request register (irq) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 125
interrupt pending function types overview there are two types of interrupt pending bits: one type that is automatically cleared by hardware after the interrupt service routine is acknowledged and executed; the other that must be cleared in the interrupt service routine. pending bits cleared automatically by hardware for interrupt pending bits that are cleared automatically by hardware, interrupt logic sets the corresponding pending bit to "1" when a request occurs. it then issues an irq pulse to inform the cpu that an interrupt is waiting to be serviced. the cpu acknowledges the interrupt source by sending an iack, executes the service routine, and clears the pending bit to "0". this type of pending bit is not mapped and cannot, therefore, be read or written by application software. in the S3F82NB interrupt structure, the timer 0 match/capture and overflow interrupt (irq0), the timer 1/a match/capture and overflow interrupt (irq1), the timer b match interrupt (irq2), the sio interrupt (irq3) belongs to this category of interrupts in which pending condition is cleared automatically by hardware. pending bits cleared by the service routine the second type of pending bit is the one that should be cleared by program software. the service routine must clear the appropriate pending bit before a return-from-interrupt subroutine (iret) occurs. to do this, a "0" must be written to the corresponding pending bit location in the sources mode or control register.   programming tip how to clear an interrupt pending bit as the following examples are shown, a load instruction should be used to clear an interrupt pending bit. examples: 1. sb1 ld p1pnd, #11111011b ; clear p1.2's interrupt pending bit iret 2. sb0 ld tintpnd, #11111101b ; clear timer 0 match/capture interrupt pending bit iret ps031601-0813 p r e l i m i n a r y S3F82NB product specification 126
interrupt source polling sequence the interrupt request polling and servicing sequence is as follows: 1. a source generates an interrupt request by setting the interrupt request bit to "1". 2. the cpu polling procedure identifies a pending condition for that source. 3. the cpu checks the sources interrupt level. 4. the cpu generates an interrupt acknowledge signal. 5. interrupt logic determines the interrupt's vector address. 6. the service routine starts and the source's pending bit is cleared to "0" (by hardware or by software). 7. the cpu continues polling for interrupt requests. interrupt service routines before an interrupt request is serviced, the following conditions must be met: interrupt processing must be globally enabled (ei, sym.0 = "1") the interrupt level must be enabled (imr register) the interrupt level must have the highest priority if more than one levels are currently requesting service the interrupt must be enabled at the interrupt's source (peripheral control register) when all the above conditions are met, the interrupt request is acknowledged at the end of the instruction cycle. the cpu then initiates an interrupt machine cycle that completes the following processing sequence: 1. reset (clear to "0") the interrupt enable bit in the sym register (sym.0) to disable all subsequent interrupts. 2. save the program counter (pc) and status flags to the system stack. 3. branch to the interrupt vector to fetch the address of the service routine. 4. pass control to the interrupt service routine. when the interrupt service routine is completed, the cpu issues an interrupt return (iret). the iret restores the pc and status flags, setting sym.0 to "1". it allows the cpu to process the next interrupt request. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 127
generating interrupt vector addresses the interrupt vector area in the rom (00hCffh) contains the addresses of interrupt service routines that correspond to each level in the interrupt structure. vectored interrupt processing follows this sequence: 1. push the program counter's low-byte value to the stack. 2. push the program counter's high-byte value to the stack. 3. push the flag register values to the stack. 4. fetch the service routine's high-byte address from the vector location. 5. fetch the service routine's low-byte address from the vector location. 6. branch to the service routine specified by the concatenated 16-bit vector address. note a 16-bit vector address always begins at an even-numbered rom address within the range of 00hCffh. nesting of vectored interrupts it is possible to nest a higher-priority interrupt request while a lower-priority request is being serviced. to do this, you must follow these steps: 1. push the current 8-bit interrupt mask register (imr) value to the stack (push imr). 2. load the imr register with a new mask value that enables only the higher priority interrupt. 3. execute an ei instruction to enable interrupt processing (a higher priority interrupt will be processed if it occurs). 4. when the lower-priority interrupt service routine ends, restore the imr to its original value by returning the previous mask value from the stack (pop imr). 5. execute an iret. depending on the application, you may be able to simplify the procedure above to some extent. instruction pointer (ip) the instruction pointer (ip) is adopted by all the s3c8-series microcontrollers to control the optional high-speed interrupt processing feature called fast interrupts . the ip consists of register pair dah and dbh. the names of ip registers are iph (high byte, ip15Cip8) and ipl (low byte, ip7Cip0). fast interrupt processing the feature called fast interrupt processing allows an interrupt within a given level to be completed in approximately 6 clock cycles rather than the usual 16 clock cycles. to select a specific interrupt level for fast interrupt processing, you write the appropriate 3-bit value to sym.4Csym.2. then, to enable fast interrupt processing for the selected level, you set sym.1 to 1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 128
fast interrupt processing (continued) two other system registers support fast interrupt processing: the instruction pointer (ip) contains the starting address of the service routine (and is later used to swap the program counter values), and when a fast interrupt occurs, the contents of the flags register is stored in an unmapped, dedicated register called flags' (flags prime). note for the S3F82NB microcontroller, the service routine for any one of the eight interrupts levels: irq0C irq7 can be selected for fast interrupt processing. procedure for initiating fast interrupts to initiate fast interrupt processing, follow these steps: 1. load the start address of the service routine into the instruction pointer (ip). 2. load the interrupt level number (irqn) into the fast interrupt selection field (sym.4Csym.2) 3. write a "1" to the fast interrupt enable bit in the sym register. fast interrupt service routine when an interrupt occurs in the level selected for fast interrupt processing, the following events occur: 1. the contents of the instruction pointer and the pc are swapped. 2. the flag register values are written to the flags' (flags prime) register. 3. the fast interrupt status bit in the flags register is set. 4. the interrupt is serviced. 5. assuming that the fast interrupt status bit is set, when the fast interrupt service routine ends, the instruction pointer and pc values are swapped back. 6. the content of flags' (flags prime) is copied automatically back to the flags register. 7. the fast interrupt status bit in flags is cleared automatically. relationship to interrupt pending bit types as described previously, there are two types of interrupt pending bits: one type that is automatically cleared by hardware after the interrupt service routine is acknowledged and executed; the other that must be cleared by the application program's interrupt service routine. you can select fast interrupt processing for interrupts with either type of pending condition clear function by hardware or by software. programming guidelines remember that the only way to enable/disable a fast interrupt is to set/clear the fast interrupt enable bit in the sym register, sym.1. executing an ei or di instruction globally enables or disables all interrupt processing, including fast interrupts. if you use fast interrupts, remember to load the ip with a new start address when the fast interrupt service routine ends. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 129
6 instruction set overview the sam8 instruction set is specifically designed to support the large register files that are typical of most sam8 microcontrollers. there are 78 instructions. the powerful data manipulation capabilities and features of the instruction set include: a full complement of 8-bit arithmetic and logic operations, including multiply and divide no special i/o instructions (i/o control/data registers are mapped directly into the register file) decimal adjustment included in binary-coded decimal (bcd) operations 16-bit (word) data can be incremented and decremented flexible instructions for bit addressing, rotate, and shift operations data types the sam8 cpu performs operations on bits, bytes, bcd digits, and two-byte words. bits in the register file can be set, cleared, complemented, and tested. bits within a byte are numbered from 7 to 0, where bit 0 is the least significant (right-most) bit. register addressing to access an individual register, an 8-bit address in the range 0-255 or the 4-bit address of a working register is specified. paired registers can be used to construct 16-bit data or 16-bit program memory or data memory addresses. for detailed information about register addressing, please refer to section 2, "address spaces." addressing modes there are seven explicit addressing modes: register (r), indirect register (ir), indexed (x), direct (da), relative (ra), immediate (im), and indirect (ia). for detailed descriptions of these addressing modes, please refer to section 3, "addressing modes." ps031601-0813 p r e l i m i n a r y S3F82NB product specification 130
table 6-1. instruction group summary mnemonic operands instruction load instructions clr dst clear ld dst,src load ldb dst,src load bit lde dst,src load external data memory ldc dst,src load program memory lded dst,src load external data memory and decrement ldcd dst,src load program memory and decrement ldei dst,src load external data memory and increment ldci dst,src load program memory and increment ldepd dst,src load external data memory with pre-decrement ldcpd dst,src load program memory with pre-decrement ldepi dst,src load external data memory with pre-increment ldcpi dst,src load program memory with pre-increment ldw dst,src load word pop dst pop from stack popud dst,src pop user stack (decrementing) popui dst,src pop user stack (incrementing) push src push to stack pushud dst,src push user stack (decrementing) pushui dst,src push user stack (incrementing) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 131
table 6-1. instruction group summary (continued) mnemonic operands instruction arithmetic instructions adc dst,src add with carry add dst,src add cp dst,src compare da dst decimal adjust dec dst decrement decw dst decrement word div dst,src divide inc dst increment incw dst increment word mult dst,src multiply sbc dst,src subtract with carry sub dst,src subtract logic instructions and dst,src logical and com dst complement or dst,src logical or xor dst,src logical exclusive or ps031601-0813 p r e l i m i n a r y S3F82NB product specification 132
table 6-1. instruction group summary (continued) mnemonic operands instruction program control instructions btjrf dst,src bit test and jump relative on false btjrt dst,src bit test and jump relative on true call dst call procedure cpije dst,src compare, increment and jump on equal cpijne dst,src compare, increment and jump on non-equal djnz r,dst decrement register and jump on non-zero enter enter exit exit iret interrupt return jp cc,dst jump on condition code jp dst jump unconditional jr cc,dst jump relative on condition code next next ret return wfi wait for interrupt bit manipulation instructions band dst,src bit and bcp dst,src bit compare bitc dst bit complement bitr dst bit reset bits dst bit set bor dst,src bit or bxor dst,src bit xor tcm dst,src test complement under mask tm dst,src test under mask ps031601-0813 p r e l i m i n a r y S3F82NB product specification 133
table 6-1. instruction group summary (concluded) mnemonic operands instruction rotate and shift instructions rl dst rotate left rlc dst rotate left through carry rr dst rotate right rrc dst rotate right through carry sra dst shift right arithmetic swap dst swap nibbles cpu control instructions ccf complement carry flag di disable interrupts ei enable interrupts idle enter idle mode nop no operation rcf reset carry flag sb0 set bank 0 sb1 set bank 1 scf set carry flag srp src set register pointers srp0 src set register pointer 0 srp1 src set register pointer 1 stop enter stop mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 134
flags register (flags) the flags register flags contains eight bits that describe the current status of cpu operations. four of these bits, flags.7Cflags.4, can be tested and used with conditional jump instructions; two others flags.3 and flags.2 are used for bcd arithmetic. the flags register also contains a bit to indicate the status of fast interrupt processing (flags.1) and a bank address status bit (flags.0) to indicate whether bank 0 or bank 1 is currently being addressed. flags register can be set or reset by instructions as long as its outcome does not affect the flags, such as, load instruction. logical and arithmetic instructions such as, and, or, xor, add, and sub can affect the flags register. for example, the and instruction updates the zero, sign and overflow flags based on the outcome of the and instruction. if the and instruction uses the flags register as the destination, then simultaneously, two write will occur to the flags register producing an unpredictable result. system flags register (flags) d5h, set 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb bank address status flag (ba) first interrupt status flag (fis) half-carry flag (h) decimal adjust flag (d) overflow (v) sign flag (s) zero flag (z) carry flag (c) figure 6-1. system flags register (flags) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 135
flag descriptions c carry flag (flags.7) the c flag is set to "1" if the result from an arithmetic operation generates a carry-out from or a borrow to the bit 7 position (msb). after rotate and shift operations, it contains the last value shifted out of the specified register. program instructions can set, clear, or complement the carry flag. z zero flag (flags.6) for arithmetic and logic operations, the z flag is set to "1" if the result of the operation is zero. for operations that test register bits, and for shift and rotate operations, the z flag is set to "1" if the result is logic zero. s sign flag (flags.5) following arithmetic, logic, rotate, or shift operations, the sign bit identifies the state of the msb of the result. a logic zero indicates a positive number and a logic one indicates a negative number. v overflow flag (flags.4) the v flag is set to "1" when the result of a two's-complement operation is greater than + 127 or less than C 128. it is also cleared to "0" following logic operations. d decimal adjust flag (flags.3) the da bit is used to specify what type of instruction was executed last during bcd operations, so that a subsequent decimal adjust operation can execute correctly. the da bit is not usually accessed by programmers, and cannot be used as a test condition. h half-carry flag (flags.2) the h bit is set to "1" whenever an addition generates a carry-out of bit 3, or when a subtraction borrows out of bit 4. it is used by the decimal adjust (da) instruction to convert the binary result of a previous addition or subtraction into the correct decimal (bcd) result. the h flag is seldom accessed directly by a program. fis fast interrupt status flag (flags.1) the fis bit is set during a fast interrupt cycle and reset during the iret following interrupt servicing. when set, it inhibits all interrupts and causes the fast interrupt return to be executed when the iret instruction is executed. ba bank address flag (flags.0) the ba flag indicates which register bank in the set 1 area of the internal register file is currently selected, bank 0 or bank 1. the ba flag is cleared to "0" (select bank 0) when you execute the sb0 instruction and is set to "1" (select bank 1) when you execute the sb1 instruction. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 136
instruction set notation table 6-2. flag notation conventions flag description c carry flag z zero flag s sign flag v overflow flag d decimal-adjust flag h half-carry flag 0 cleared to logic zero 1 set to logic one * set or cleared according to operation C value is unaffected x value is undefined table 6-3. instruction set symbols symbol description dst destination operand src source operand @ indirect register address prefix pc program counter ip instruction pointer flags flags register (d5h) rp register pointer # immediate operand or register address prefix h hexadecimal number suffix d decimal number suffix b binary number suffix opc opcode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 137
table 6-4. instruction notation conventions notation description actual operand range cc condition code see list of condition codes in table 6-6. r working register only rn (n = 0C15) rb bit (b) of working register rn.b (n = 0C15, b = 0C7) r0 bit 0 (lsb) of working register rn (n = 0C15) rr working register pair rrp (p = 0, 2, 4, ..., 14) r register or working register reg or rn (reg = 0C255, n = 0C15) rb bit 'b' of register or working register reg.b (reg = 0C255, b = 0C7) rr register pair or working register pair reg or rrp (reg = 0C254, even number only, where p = 0, 2, ..., 14) ia indirect addressing mode addr (addr = 0C254, even number only) ir indirect working register only @rn (n = 0C15) ir indirect register or indirect working register @rn or @reg (reg = 0C255, n = 0C15) irr indirect working register pair only @rrp (p = 0, 2, ..., 14) irr indirect register pair or indirect working register pair @rrp or @reg (reg = 0C254, even only, where p = 0, 2, ..., 14) x indexed addressing mode #reg [rn] (reg = 0C255, n = 0C15) xs indexed (short offset) addressing mode #addr [rrp] (addr = range C128 to +127, where p = 0, 2, ..., 14) xl indexed (long offset) addressing mode #addr [rrp] (addr = range 0C65535, where p = 0, 2, ..., 14) da direct addressing mode addr (addr = range 0C65535) ra relative addressing mode addr (addr = number in the range +127 to C128 that is an offset relative to the address of the next instruction) im immediate addressing mode #data (data = 0C255) iml immediate (long) addressing mode #data (data = range 0C65535) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 138
table 6-5. opcode quick reference opcode map lower nibble (hex) C 0 1 2 3 4 5 6 7 u 0 dec r1 dec ir1 add r1,r2 add r1,ir2 add r2,r1 add ir2,r1 add r1,im bor r0Crb p 1 rlc r1 rlc ir1 adc r1,r2 adc r1,ir2 adc r2,r1 adc ir2,r1 adc r1,im bcp r1.b, r2 p 2 inc r1 inc ir1 sub r1,r2 sub r1,ir2 sub r2,r1 sub ir2,r1 sub r1,im bxor r0Crb e 3 jp irr1 srp/0/1 im sbc r1,r2 sbc r1,ir2 sbc r2,r1 sbc ir2,r1 sbc r1,im btjr r2.b, ra r 4 da r1 da ir1 or r1,r2 or r1,ir2 or r2,r1 or ir2,r1 or r1,im ldb r0Crb 5 pop r1 pop ir1 and r1,r2 and r1,ir2 and r2,r1 and ir2,r1 and r1,im bitc r1.b n 6 com r1 com ir1 tcm r1,r2 tcm r1,ir2 tcm r2,r1 tcm ir2,r1 tcm r1,im band r0Crb i 7 push r2 push ir2 tm r1,r2 tm r1,ir2 tm r2,r1 tm ir2,r1 tm r1,im bit r1.b b 8 decw rr1 decw ir1 pushud ir1,r2 pushui ir1,r2 mult r2,rr1 mult ir2,rr1 mult im,rr1 ld r1, x, r2 b 9 rl r1 rl ir1 popud ir2,r1 popui ir2,r1 div r2,rr1 div ir2,rr1 div im,rr1 ld r2, x, r1 l a incw rr1 incw ir1 cp r1,r2 cp r1,ir2 cp r2,r1 cp ir2,r1 cp r1,im ldc r1, irr2, xl e b clr r1 clr ir1 xor r1,r2 xor r1,ir2 xor r2,r1 xor ir2,r1 xor r1,im ldc r2, irr2, xl c rrc r1 rrc ir1 cpije ir,r2,ra ldc r1,irr2 ldw rr2,rr1 ldw ir2,rr1 ldw rr1,iml ld r1, ir2 h d sra r1 sra ir1 cpijne irr,r2,ra ldc r2,irr1 call ia1 ld ir1,im ld ir1, r2 e e rr r1 rr ir1 ldcd r1,irr2 ldci r1,irr2 ld r2,r1 ld r2,ir1 ld r1,im ldc r1, irr2, xs x f swap r1 swap ir1 ldcpd r2,irr1 ldcpi r2,irr1 call irr1 ld ir2,r1 call da1 ldc r2, irr1, xs ps031601-0813 p r e l i m i n a r y S3F82NB product specification 139
table 6-5. opcode quick reference (continued) opcode map lower nibble (hex) C 8 9 a b c d e f u 0 ld r1,r2 ld r2,r1 djnz r1,ra jr cc,ra ld r1,im jp cc,da inc r1 next p 1 enter p 2 e x i t e 3 w f i r 4 sb0 5 s b 1 n 6 idle i 7 stop b 8 di b 9 ei l a ret e b iret c r c f h d scf e e ccf x f ld r1,r2 ld r2,r1 djnz r1,ra jr cc,ra ld r1,im jp cc,da inc r1 nop ps031601-0813 p r e l i m i n a r y S3F82NB product specification 140
condition codes the opcode of a conditional jump always contains a 4-bit field called the condition code (cc). this specifies under which conditions it is to execute the jump. for example, a conditional jump with the condition code for "equal" after a compare operation only jumps if the two operands are equal. condition codes are listed in table 6-6. the carry (c), zero (z), sign (s), and overflow (v) flags are used to control the operation of conditional jump instructions. table 6-6. condition codes binary mnemonic description flags set 0000 f always false C 1000 t always true C 0111 (note) c carry c = 1 1111 (note) nc no carry c = 0 0110 (note) z zero z = 1 1110 (note) nz not zero z = 0 1101 pl plus s = 0 0101 mi minus s = 1 0100 ov overflow v = 1 1100 nov no overflow v = 0 0110 (note) eq equal z = 1 1110 (note) ne not equal z = 0 1001 ge greater than or equal (s xor v) = 0 0001 lt less than (s xor v) = 1 1010 gt greater than (z or (s xor v)) = 0 0010 le less than or equal (z or (s xor v)) = 1 1111 (note) uge unsigned greater than or equal c = 0 0111 (note) ult unsigned less than c = 1 1011 ugt unsigned greater than (c = 0 and z = 0) = 1 0011 ule unsigned less than or equal (c or z) = 1 notes: 1. it indicates condition codes that are related to two different mnemonics but which test the same flag. for example, z and eq are both true if the zero flag (z) is set, but after an add instruction, z would probably be used; after a cp instruction, however, eq would probably be used. 2. for operations involving unsigned numbers, the special condition codes uge, ult, ugt, and ule must be used. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 141
instruction descriptions this section contains detailed information and programming examples for each instruction in the sam8 instruction set. information is arranged in a consistent format for improved readability and for fast referencing. the following information is included in each instruction description: instruction name (mnemonic) full instruction name source/destination format of the instruction operand shorthand notation of the instruction's operation textual description of the instruction's effect specific flag settings affected by the instruction detailed description of the instruction's format, execution time, and addressing mode(s) programming example(s) explaining how to use the instruction ps031601-0813 p r e l i m i n a r y S3F82NB product specification 142
adc add with carry adc dst,src operation: dst  dst + src + c the source operand, along with the setting of the carry flag, is added to the destination operand and the sum is stored in the destination. the contents of the source are unaffected. two's- complement addition is performed. in multiple precision arithmetic, this instruction permits the carry from the addition of low-order operands to be carried into the addition of high-order operands. flags: c: set if there is a carry from the most significant bit of the result; cleared otherwise. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurs, that is, if both operands are of the same sign and the result is of the opposite sign; cleared otherwise. d: always cleared to "0". h: set if there is a carry from the most significant bit of the low-order four bits of the result; cleared otherwise. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 12 r r 6 13 r lr opc src dst 3 6 14 r r 6 15 r ir opc dst src 3 6 16 r im examples: given: r1 = 10h, r2 = 03h, c flag = "1", register 01h = 20h, register 02h = 03h, and register 03h = 0ah: adc r1,r2  r1 = 14h, r2 = 03h adc r1,@r2  r1 = 1bh, r2 = 03h adc 01h,02h  register 01h = 24h, register 02h = 03h adc 01h,@02h  register 01h = 2bh, register 02h = 03h adc 01h,#11h  register 01h = 32h in the first example, destination register r1 contains the value 10h, the carry flag is set to "1", and the source working register r2 contains the value 03h. the statement "adc r1,r2" adds 03h and the carry flag value ("1") to the destination value 10h, leaving 14h in register r1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 143
add add add dst,src operation: dst  dst + src the source operand is added to the destination operand and the sum is stored in the destination. the contents of the source are unaffected. two's-complement addition is performed. flags: c: set if there is a carry from the most significant bit of the result; cleared otherwise. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurred, that is, if both operands are of the same sign and the result is of the opposite sign; cleared otherwise. d: always cleared to "0". h: set if a carry from the low-order nibble occurred. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 02 r r 6 03 r lr opc src dst 3 6 04 r r 6 05 r ir opc dst src 3 6 06 r im examples: given: r1 = 12h, r2 = 03h, register 01h = 21h, register 02h = 03h, register 03h = 0ah: add r1,r2  r1 = 15h, r2 = 03h add r1,@r2  r1 = 1ch, r2 = 03h add 01h,02h  register 01h = 24h, register 02h = 03h add 01h,@02h  register 01h = 2bh, register 02h = 03h add 01h,#25h  register 01h = 46h in the first example, destination working register r1 contains 12h and the source working register r2 contains 03h. the statement "add r1,r2" adds 03h to 12h, leaving the value 15h in register r1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 144
and logical and and dst,src operation: dst  dst and src the source operand is logically anded with the destination operand. the result is stored in the destination. the and operation results in a "1" bit being stored whenever the corresponding bits in the two operands are both logic ones; otherwise a "0" bit value is stored. the contents of the source are unaffected. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: always cleared to "0". d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 52 r r 6 53 r lr opc src dst 3 6 54 r r 6 55 r ir opc dst src 3 6 56 r im examples: given: r1 = 12h, r2 = 03h, register 01h = 21h, register 02h = 03h, register 03h = 0ah: and r1,r2  r1 = 02h, r2 = 03h and r1,@r2  r1 = 02h, r2 = 03h and 01h,02h  register 01h = 01h, register 02h = 03h and 01h,@02h  register 01h = 00h, register 02h = 03h and 01h,#25h  register 01h = 21h in the first example, destination working register r1 contains the value 12h and the source working register r2 contains 03h. the statement "and r1,r2" logically ands the source operand 03h with the destination operand value 12h, leaving the value 02h in register r1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 145
band bit and band dst,src.b band dst.b,src operation: dst(0)  dst(0) and src(b) or dst(b)  dst(b) and src(0) the specified bit of the source (or the destination) is logically anded with the zero bit (lsb) of the destination (or source). the resultant bit is stored in the specified bit of the destination. no other bits of the destination are affected. the source is unaffected. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: cleared to "0". v: undefined. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | b | 0 src 3 6 67 r0 rb opc src | b | 1 dst 3 6 67 rb r0 note : in the second byte of the 3-byte instruction formats, the destination (or source) address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. examples: given: r1 = 07h and register 01h = 05h: band r1,01h.1  r1 = 06h, register 01h = 05h band 01h.1,r1  register 01h = 05h, r1 = 07h in the first example, source register 01h contains the value 05h (00000101b) and destination working register r1 contains 07h (00000111b). the statement "band r1,01h.1" ands the bit 1 value of the source register ("0") with the bit 0 value of register r1 (destination), leaving the value 06h (00000110b) in register r1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 146
bcp bit compare bcp dst,src.b operation: dst(0) C src(b) the specified bit of the source is compared to (subtracted from) bit zero (lsb) of the destination. the zero flag is set if the bits are the same; otherwise it is cleared. the contents of both operands are unaffected by the comparison. flags: c: unaffected. z: set if the two bits are the same; cleared otherwise. s: cleared to "0". v: undefined. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | b | 0 src 3 6 17 r0 rb note : in the second byte of the instruction format, the destination address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. example: given: r1 = 07h and register 01h = 01h: bcp r1,01h.1  r1 = 07h, register 01h = 01h if destination working register r1 contains the value 07h (00000111b) and the source register 01h contains the value 01h (00000001b), the statement "bcp r1,01h.1" compares bit one of the source register (01h) and bit zero of the destination register (r1). because the bit values are not identical, the zero flag bit (z) is cleared in the flags register (0d5h). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 147
bitc bit complement bitc dst.b operation: dst(b)  not dst(b) this instruction complements the specified bit within the destination without affecting any other bits in the destination. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: cleared to "0". v: undefined. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst | b | 0 2 4 57 rb note : in the second byte of the instruction format, the destination address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. example: given: r1 = 07h bitc r1.1  r1 = 05h if working register r1 contains the value 07h (00000111b), the statement "bitc r1.1" complements bit one of the destination and leaves the value 05h (00000101b) in register r1. because the result of the complement is not "0", the zero flag (z) in the flags register (0d5h) is cleared. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 148
bitr bit reset bitr dst.b operation: dst(b)  0 the bitr instruction clears the specified bit within the destination without affecting any other bits in the destination. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst opc dst | b | 0 2 4 77 rb note : in the second byte of the instruction format, the destination address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. example: given: r1 = 07h: bitr r1.1  r1 = 05h if the value of working register r1 is 07h (00000111b), the statement "bitr r1.1" clears bit one of the destination register r1, leaving the value 05h (00000101b). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 149
bits bit set bits dst.b operation: dst(b)  1 the bits instruction sets the specified bit within the destination without affecting any other bits in the destination. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst opc dst | b | 1 2 4 77 rb note : in the second byte of the instruction format, the destination address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. example: given: r1 = 07h: bits r1.3  r1 = 0fh if working register r1 contains the value 07h (00000111b), the statement "bits r1.3" sets bit three of the destination register r1 to "1", leaving the value 0fh (00001111b). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 150
bor bit or bor dst,src.b bor dst.b,src operation: dst(0)  dst(0) or src(b) or dst(b)  dst(b) or src(0) the specified bit of the source (or the destination) is logically ored with bit zero (lsb) of the destination (or the source). the resulting bit value is stored in the specified bit of the destination. no other bits of the destination are affected. the source is unaffected. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: cleared to "0". v: undefined. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | b | 0 src 3 6 07 r0 rb opc src | b | 1 dst 3 6 07 rb r0 note : in the second byte of the 3-byte instruction formats, the destination (or source) address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit. examples: given: r1 = 07h and register 01h = 03h: bor r1, 01h.1  r1 = 07h, register 01h = 03h bor 01h.2, r1  register 01h = 07h, r1 = 07h in the first example, destination working register r1 contains the value 07h (00000111b) and source register 01h the value 03h (00000011b). the statement "bor r1,01h.1" logically ors bit one of register 01h (source) with bit zero of r1 (destination). this leaves the same value (07h) in working register r1. in the second example, destination register 01h contains the value 03h (00000011b) and the source working register r1 the value 07h (00000111b). the statement "bor 01h.2,r1" logically ors bit two of register 01h (destination) with bit zero of r1 (source). this leaves the value 07h in register 01h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 151
btjrf bit test, jump relative on false btjrf dst,src.b operation: if src(b) is a "0", then pc  pc + dst the specified bit within the source operand is tested. if it is a "0", the relative address is added to the program counter and control passes to the statement whose address is now in the pc; otherwise, the instruction following the btjrf instruction is executed. flags: no flags are affected. format: (note 1) bytes cycles opcode (hex) addr mode dst src opc src | b | 0 dst 3 10 37 ra rb note: in the second byte of the instruction format, the source address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. example: given: r1 = 07h: btjrf skip,r1.3  pc jumps to skip location if working register r1 contains the value 07h (00000111b), the statement "btjrf skip,r1.3" tests bit 3. because it is "0", the relative address is added to the pc and the pc jumps to the memory location pointed to by the skip. (remember that the memory location must be within the allowed range of + 127 to C 128.) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 152
btjrt bit test, jump relative on true btjrt dst,src.b operation: if src(b) is a "1", then pc  pc + dst the specified bit within the source operand is tested. if it is a "1", the relative address is added to the program counter and control passes to the statement whose address is now in the pc; otherwise, the instruction following the btjrt instruction is executed. flags: no flags are affected. format: (note 1) bytes cycles opcode (hex) addr mode dst src opc src | b | 1 dst 3 10 37 ra rb note: in the second byte of the instruction format, the source address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. example: given: r1 = 07h: btjrt skip,r1.1 if working register r1 contains the value 07h (00000111b), the statement "btjrt skip,r1.1" tests bit one in the source register (r1). because it is a "1", the relative address is added to the pc and the pc jumps to the memory location pointed to by the skip. (remember that the memory location must be within the allowed range of + 127 to C 128.) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 153
bxor bit xor bxor dst,src.b bxor dst.b,src operation: dst(0)  dst(0) xor src(b) or dst(b)  dst(b) xor src(0) the specified bit of the source (or the destination) is logically exclusive-ored with bit zero (lsb) of the destination (or source). the result bit is stored in the specified bit of the destination. no other bits of the destination are affected. the source is unaffected. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: cleared to "0". v: undefined. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | b | 0 src 3 6 27 r0 rb opc src | b | 1 dst 3 6 27 rb r0 note : in the second byte of the 3-byte instruction formats, the destination (or source) address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. examples: given: r1 = 07h (00000111b) and register 01h = 03h (00000011b): bxor r1,01h.1  r1 = 06h, register 01h = 03h bxor 01h.2,r1  register 01h = 07h, r1 = 07h in the first example, destination working register r1 has the value 07h (00000111b) and source register 01h has the value 03h (00000011b). the statement "bxor r1,01h.1" exclusive-ors bit one of register 01h (source) with bit zero of r1 (destination). the result bit value is stored in bit zero of r1, changing its value from 07h to 06h. the value of source register 01h is unaffected. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 154
call call procedure call dst operation: sp  sp C 1 @sp  pcl sp  sp C1 @sp  pch pc  dst the current contents of the program counter are pushed onto the top of the stack. the program counter value used is the address of the first instruction following the call instruction. the specified destination address is then loaded into the program counter and points to the first instruction of a procedure. at the end of the procedure the return instruction (ret) can be used to return to the original program flow. ret pops the top of the stack back into the program counter. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst opc dst 3 14 f6 da opc dst 2 12 f4 irr opc dst 2 14 d4 ia examples: given: r0 = 35h, r1 = 21h, pc = 1a47h, and sp = 0002h: call 3521h  sp = 0000h (memory locations 0000h = 1ah, 0001h = 4ah, where 4ah is the address that follows the instruction.) call @rr0  sp = 0000h (0000h = 1ah, 0001h = 49h) call #40h  sp = 0000h (0000h = 1ah, 0001h = 49h) in the first example, if the program counter value is 1a47h and the stack pointer contains the value 0002h, the statement "call 3521h" pushes the current pc value onto the top of the stack. the stack pointer now points to memory location 0000h. the pc is then loaded with the value 3521h, the address of the first instruction in the program sequence to be executed. if the contents of the program counter and stack pointer are the same as in the first example, the statement "call @rr0" produces the same result except that the 49h is stored in stack location 0001h (because the two-byte instruction format was used). the pc is then loaded with the value 3521h, the address of the first instruction in the program sequence to be executed. assuming that the contents of the program counter and stack pointer are the same as in the first example, if program address 0040h contains 35h and program address 0041h contains 21h, the statement " call #40h " produces the same result as in the second example ps031601-0813 p r e l i m i n a r y S3F82NB product specification 155
ccf complement carry flag ccf operation: c  not c the carry flag (c) is complemented. if c = "1", the value of the carry flag is changed to logic zero; if c = "0", the value of the carry flag is changed to logic one. flags: c: complemented. no other flags are affected. format: bytes cycles opcode (hex) opc 1 4 ef example: given: the carry flag = "0": ccf if the carry flag = "0", the ccf instruction complements it in the flags register (0d5h), changing its value from logic zero to logic one. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 156
clr clear clr dst operation: dst  "0" the destination location is cleared to "0". flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 b0 r 4 b1 ir examples: given: register 00h = 4fh, register 01h = 02h, and register 02h = 5eh: clr 00h  register 00h = 00h clr @01h  register 01h = 02h, register 02h = 00h in register (r) addressing mode, the statement "clr 00h" clears the destination register 00h value to 00h. in the second example, the statement "clr @01h" uses indirect register (ir) addressing mode to clear the 02h register value to 00h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 157
com complement com dst operation: dst  not dst the contents of the destination location are complemented (one's complement); all "1s" are changed to "0s", and vice-versa. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: always reset to "0". d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 60 r 4 61 ir examples: given: r1 = 07h and register 07h = 0f1h: com r1  r1 = 0f8h com @r1  r1 = 07h, register 07h = 0eh in the first example, destination working register r1 contains the value 07h (00000111b). the statement "com r1" complements all the bits in r1: all logic ones are changed to logic zeros, and vice-versa, leaving the value 0f8h (11111000b). in the second example, indirect register (ir) addressing mode is used to complement the value of destination register 07h (11110001b), leaving the new value 0eh (00001110b). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 158
cp compare cp dst,src operation: dst C src the source operand is compared to (subtracted from) the destination operand, and the appropriate flags are set accordingly. the contents of both operands are unaffected by the comparison. flags: c: set if a "borrow" occurred (src > dst); cleared otherwise. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurred; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 a2 r r 6 a3 r lr opc src dst 3 6 a4 r r 6 a5 r ir opc dst src 3 6 a6 r im examples: 1. given: r1 = 02h and r2 = 03h: cp r1,r2  set the c and s flags destination working register r1 contains the value 02h and source register r2 contains the value 03h. the statement "cp r1,r2" subtracts the r2 value (source/subtrahend) from the r1 value (destination/minuend). because a "borrow" occurs and the difference is negative, c and s are "1". 2. given: r1 = 05h and r2 = 0ah: cp r1,r2 jp uge,skip inc r1 skip ld r3,r1 in this example, destination working register r1 contains the value 05h which is less than the contents of the source working register r2 (0ah). the statement "cp r1,r2" generates c = "1" and the jp instruction does not jump to the skip location. after the statement "ld r3,r1" executes, the value 06h remains in working register r3. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 159
cpije compare, increment, and jump on equal cpije dst,src,ra operation: if dst C src = "0", pc  pc + ra ir  ir + 1 the source operand is compared to (subtracted from) the destination operand. if the result is "0", the relative address is added to the program counter and control passes to the statement whose address is now in the program counter. otherwise, the instruction immediately following the cpije instruction is executed. in either case, the source pointer is incremented by one before the next instruction is executed. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc src dst ra 3 12 c2 r ir note: execution time is 18 cycles if the jump is taken or 16 cycles if it is not taken. example: given: r1 = 02h, r2 = 03h, and register 03h = 02h: cpije r1,@r2,skip  r2 = 04h, pc jumps to skip location in this example, working register r1 contains the value 02h, working register r2 the value 03h, and register 03 contains 02h. the statement "cpije r1,@r2,skip" compares the @r2 value 02h (00000010b) to 02h (00000010b). because the result of the comparison is equal, the relative address is added to the pc and the pc then jumps to the memory location pointed to by skip. the source register (r2) is incremented by one, leaving a value of 04h. (remember that the memory location must be within the allowed range of + 127 to C 128.) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 160
cpijne compare, increment, and jump on non-equal cpijne dst,src,ra operation: if dst C src "0", pc  pc + ra ir  ir + 1 the source operand is compared to (subtracted from) the destination operand. if the result is not "0", the relative address is added to the program counter and control passes to the statement whose address is now in the program counter; otherwise the instruction following the cpijne instruction is executed. in either case the source pointer is incremented by one before the next instruction. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc src dst ra 3 12 d2 r ir note: execution time is 18 cycles if the jump is taken or 16 cycles if it is not taken. example: given: r1 = 02h, r2 = 03h, and register 03h = 04h: cpijne r1,@r2,skip  r2 = 04h, pc jumps to skip location working register r1 contains the value 02h, working register r2 (the source pointer) the value 03h, and general register 03 the value 04h. the statement "cpijne r1,@r2,skip" subtracts 04h (00000100b) from 02h (00000010b). because the result of the comparison is non-equal, the relative address is added to the pc and the pc then jumps to the memory location pointed to by skip. the source pointer register (r2) is also incremented by one, leaving a value of 04h. (remember that the memory location must be within the allowed range of + 127 to C 128.) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 161
da decimal adjust da dst operation: dst  da dst the destination operand is adjusted to form two 4-bit bcd digits following an addition or subtraction operation. for addition (add, adc) or subtraction (sub, sbc), the following table indicates the operation performed. (the operation is undefined if the destination operand was not the result of a valid addition or subtraction of bcd digits): instruction carry before da bits 4C7 value (hex) h flag before da bits 0C3 value (hex) number added to byte carry after da 0 0C9 0 0C9 00 0 0 0C8 0 aCf 06 0 0 0C9 1 0C3 06 0 add 0 aCf 0 0C9 60 1 adc 0 9Cf 0 aCf 66 1 0 aCf 1 0C3 66 1 1 0C2 0 0C9 60 1 1 0C2 0 aCf 66 1 1 0C3 1 0C3 66 1 0 0C9 0 0C9 00 = C 00 0 sub 0 0C8 1 6Cf fa = C 06 0 sbc 1 7Cf 0 0C9 a0 = C 60 1 1 6Cf 1 6Cf 9a = C 66 1 flags: c: set if there was a carry from the most significant bit; cleared otherwise (see table). z: set if result is "0"; cleared otherwise. s: set if result bit 7 is set; cleared otherwise. v: undefined. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 40 r 4 41 ir ps031601-0813 p r e l i m i n a r y S3F82NB product specification 162
da decimal adjust da (continued) example: given: working register r0 contains the value 15 (bcd), working register r1 contains 27 (bcd), and address 27h contains 46 (bcd): add r1,r0 ; c  "0", h  "0", bits 4C7 = 3, bits 0C3 = c, r1  3ch da r1 ; r1  3ch + 06 if addition is performed using the bcd values 15 and 27, the result should be 42. the sum is incorrect, however, when the binary representations are added in the destination location using standard binary arithmetic: 0 0 0 1 0 1 0 1 15 + 0 0 1 0 0 1 1 1 27 0 0 1 1 1 1 0 0 = 3ch the da instruction adjusts this result so that the correct bcd representation is obtained: 0 0 1 1 1 1 0 0 + 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 = 42 assuming the same values given above, the statements sub 27h,r0 ; c  "0", h  "0", bits 4C7 = 3, bits 0C3 = 1 da @r1 ; @r1  31C0 leave the value 31 (bcd) in address 27h (@r1). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 163
dec decrement dec dst operation: dst  dst C 1 the contents of the destination operand are decremented by one. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if result is negative; cleared otherwise. v: set if arithmetic overflow occurred; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 00 r 4 01 ir examples: given: r1 = 03h and register 03h = 10h: dec r1  r1 = 02h dec @r1  register 03h = 0fh in the first example, if working register r1 contains the value 03h, the statement "dec r1" decrements the hexadecimal value by one, leaving the value 02h. in the second example, the statement "dec @r1" decrements the value 10h contained in the destination register 03h by one, leaving the value 0fh. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 164
decw decrement word decw dst operation: dst  dst C 1 the contents of the destination location (which must be an even address) and the operand following that location are treated as a single 16-bit value that is decremented by one. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurred; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 8 80 rr 8 81 ir examples: given: r0 = 12h, r1 = 34h, r2 = 30h, register 30h = 0fh, and register 31h = 21h: decw rr0  r0 = 12h, r1 = 33h decw @r2  register 30h = 0fh, register 31h = 20h in the first example, destination register r0 contains the value 12h and register r1 the value 34h. the statement "decw rr0" addresses r0 and the following operand r1 as a 16-bit word and decrements the value of r1 by one, leaving the value 33h. note: a system malfunction may occur if you use a zero flag (flags.6) result together with a decw instruction. to avoid this problem, we recommend that you use decw as shown in the following example: loop: decw rr0 ld r2,r1 or r2,r0 jr nz,loop ps031601-0813 p r e l i m i n a r y S3F82NB product specification 165
di disable interrupts di operation: sym (0)  0 bit zero of the system mode control register, sym.0, is cleared to "0", globally disabling all interrupt processing. interrupt requests will continue to set their respective interrupt pending bits, but the cpu will not service them while interrupt processing is disabled. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 4 8f example: given: sym = 01h: di if the value of the sym register is 01h, the statement "di" leaves the new value 00h in the register and clears sym.0 to "0", disabling interrupt processing. before changing imr, interrupt pending and interrupt source control register, be sure di state. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 166
div divide (unsigned) div dst,src operation: dst src dst (upper)  remainder dst (lower)  quotient the destination operand (16 bits) is divided by the source operand (8 bits). the quotient (8 bits) is stored in the lower half of the destination. the remainder (8 bits) is stored in the upper half of the destination. when the quotient is 2 8 , the numbers stored in the upper and lower halves of the destination for quotient and remainder are incorrect. both operands are treated as unsigned integers. flags: c: set if the v flag is set and quotient is between 2 8 and 2 9 C1; cleared otherwise. z: set if divisor or quotient = "0"; cleared otherwise. s: set if msb of quotient = "1"; cleared otherwise. v: set if quotient is 2 8 or if divisor = "0"; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc src dst 3 26/10 94 rr r 26/10 95 rr ir 26/10 96 rr im note: execution takes 10 cycles if the divide-by-zero is attempted; otherwise it takes 26 cycles. examples: given: r0 = 10h, r1 = 03h, r2 = 40h, register 40h = 80h: div rr0,r2  r0 = 03h, r1 = 40h div rr0,@r2  r0 = 03h, r1 = 20h div rr0,#20h  r0 = 03h, r1 = 80h in the first example, destination working register pair rr0 contains the values 10h (r0) and 03h (r1), and register r2 contains the value 40h. the statement "div rr0,r2" divides the 16-bit rr0 value by the 8-bit value of the r2 (source) register. after the div instruction, r0 contains the value 03h and r1 contains 40h. the 8-bit remainder is stored in the upper half of the destination register rr0 (r0) and the quotient in the lower half (r1). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 167
djnz decrement and jump if non-zero djnz r,dst operation: r  r C 1 if r 0, pc  pc + dst the working register being used as a counter is decremented. if the contents of the register are not logic zero after decrementing, the relative address is added to the program counter and control passes to the statement whose address is now in the pc. the range of the relative address is +127 to C128, and the original value of the pc is taken to be the address of the instruction byte following the djnz statement. note: in case of using djnz instruction, the working register being used as a counter should be set at the one of location 0c0h to 0cfh with srp, srp0, or srp1 instruction. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst r | opc dst 2 8 (jump taken) ra ra 8 (no jump) r = 0 to f example: given: r1 = 02h and loop is the label of a relative address: srp #0c0h djnz r1,loop djnz is typically used to control a "loop" of instructions. in many cases, a label is used as the destination operand instead of a numeric relative address value. in the example, working register r1 contains the value 02h, and loop is the label for a relative address. the statement "djnz r1, loop" decrements register r1 by one, leaving the value 01h. because the contents of r1 after the decrement are non-zero, the jump is taken to the relative address specified by the loop label. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 168
ei enable interrupts ei operation: sym (0)  1 an ei instruction sets bit zero of the system mode register, sym.0 to "1". this allows interrupts to be serviced as they occur (assuming they have highest priority). if an interrupt's pending bit was set while interrupt processing was disabled (by executing a di instruction), it will be serviced when you execute the ei instruction. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 4 9f example: given: sym = 00h: ei if the sym register contains the value 00h, that is, if interrupts are currently disabled, the statement "ei" sets the sym register to 01h, enabling all interrupts. (sym.0 is the enable bit for global interrupt processing.) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 169
enter enter enter operation: sp  sp C 2 @sp  ip ip  pc pc  @ip ip  ip + 2 this instruction is useful when implementing threaded-code languages. the contents of the instruction pointer are pushed to the stack. the program counter (pc) value is then written to the instruction pointer. the program memory word that is pointed to by the instruction pointer is loaded into the pc, and the instruction pointer is incremented by two. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 14 1f example: the diagram below shows one example of how to use an enter statement. 0050 ip 0022 sp 22 data address data 0040 pc 40 41 42 43 enter address h address l address h address data 1f 01 10 memory 0043 ip 0020 sp 20 21 22 iph ipl data address data 0110 pc 40 41 42 43 enter address h address l address h address data 1f 01 10 memory 00 50 stack stack 110 routine before after ps031601-0813 p r e l i m i n a r y S3F82NB product specification 170
exit exit exit operation: ip  @sp sp  sp + 2 pc  @ip ip  ip + 2 this instruction is useful when implementing threaded-code languages. the stack value is popped and loaded into the instruction pointer. the program memory word that is pointed to by the instruction pointer is then loaded into the program counter, and the instruction pointer is incremented by two. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 14 (internal stack) 2f 16 (internal stack) example: the diagram below shows one example of how to use an exit statement. 0050 ip 0022 sp address data 0040 pc address data memory 0052 ip 0022 sp address data 0060 pc address data memory stack stack before after 22 data 20 21 22 iph ipl data 00 50 50 51 140 pcl old pch exit 60 00 2f 60 main ps031601-0813 p r e l i m i n a r y S3F82NB product specification 171
idle idle operation idle operation: the idle instruction stops the cpu clock while allowing system clock oscillation to continue. idle mode can be released by an interrupt request (irq) or an external reset operation. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc 1 4 6f C C example: the instruction idle stops the cpu clock but not the system clock. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 172
inc increment inc dst operation: dst  dst + 1 the contents of the destination operand are incremented by one. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurred; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst dst | opc 1 4 re r r = 0 to f opc dst 2 4 20 r 4 21 ir examples: given: r0 = 1bh, register 00h = 0ch, and register 1bh = 0fh: inc r0  r0 = 1ch inc 00h  register 00h = 0dh inc @r0  r0 = 1bh, register 01h = 10h in the first example, if destination working register r0 contains the value 1bh, the statement "inc r0" leaves the value 1ch in that same register. the next example shows the effect an inc instruction has on register 00h, assuming that it contains the value 0ch. in the third example, inc is used in indirect register (ir) addressing mode to increment the value of register 1bh from 0fh to 10h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 173
incw increment word incw dst operation: dst  dst + 1 the contents of the destination (which must be an even address) and the byte following that location are treated as a single 16-bit value that is incremented by one. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurred; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 8 a0 rr 8 a1 ir examples: given: r0 = 1ah, r1 = 02h, register 02h = 0fh, and register 03h = 0ffh: incw rr0  r0 = 1ah, r1 = 03h incw @r1  register 02h = 10h, register 03h = 00h in the first example, the working register pair rr0 contains the value 1ah in register r0 and 02h in register r1. the statement "incw rr0" increments the 16-bit destination by one, leaving the value 03h in register r1. in the second example, the statement "incw @r1" uses indirect register (ir) addressing mode to increment the contents of general register 03h from 0ffh to 00h and register 02h from 0fh to 10h. note: a system malfunction may occur if you use a zero (z) flag (flags.6) result together with an incw instruction. to avoid this problem, we recommend that you use incw as shown in the following example: loop: incw rr0 ld r2,r1 or r2,r0 jr nz,loop ps031601-0813 p r e l i m i n a r y S3F82NB product specification 174
iret interrupt return iret iret (normal) iret (fast) operation: flags  @sp pc  ip sp  sp + 1 flags  flags' pc  @sp fis  0 sp  sp + 2 sym(0)  1 this instruction is used at the end of an interrupt service routine. it restores the flag register and the program counter. it also re-enables global interrupts. a "normal iret" is executed only if the fast interrupt status bit (fis, bit one of the flags register, 0d5h) is cleared (= "0"). if a fast interrupt occurred, iret clears the fis bit that was set at the beginning of the service routine. flags: all flags are restored to their original settings (that is, the settings before the interrupt occurred). format: iret (normal) bytes cycles opcode (hex) opc 1 10 (internal stack) bf 12 (internal stack) iret (fast) bytes cycles opcode (hex) opc 1 6 bf example: in the figure below, the instruction pointer is initially loaded with 100h in the main program before interrupts are enabled. when an interrupt occurs, the program counter and instruction pointer are swapped. this causes the pc to jump to address 100h and the ip to keep the return address. the last instruction in the service routine normally is a jump to iret at address ffh. this causes the instruction pointer to be loaded with 100h "again" and the program counter to jump back to the main program. now, the next interrupt can occur and the ip is still correct at 100h. iret interrupt service routine jp to ffh 0h ffh 100h ffffh note: in the fast interrupt example above, if the last instruction is not a jump to iret, you must pay attention to the order of the last two instructions. the iret cannot be immediately proceeded by a clearing of the interrupt status (as with a reset of the ipr register). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 175
jp jump jp cc,dst (conditional) jp dst (unconditional) operation: if cc is true, pc  dst the conditional jump instruction transfers program control to the destination address if the condition specified by the condition code (cc) is true; otherwise, the instruction following the jp instruction is executed. the unconditional jp simply replaces the contents of the pc with the contents of the specified register pair. control then passes to the statement addressed by the pc. flags: no flags are affected. format: (1) (2) bytes cycles opcode (hex) addr mode dst cc | opc dst 3 8 ccd da cc = 0 to f opc dst 2 8 30 irr notes : 1. the 3-byte format is used for a conditional jump and the 2-byte format for an unconditional jump. 2. in the first byte of the three-byte instruction format (conditional jump), the condition code and the opcode are both four bits. examples: given: the carry flag (c) = "1", register 00 = 01h, and register 01 = 20h: jp c,label_w  label_w = 1000h, pc = 1000h jp @00h  pc = 0120h the first example shows a conditional jp. assuming that the carry flag is set to "1", the statement "jp c,label_w" replaces the contents of the pc with the value 1000h and transfers control to that location. had the carry flag not been set, control would then have passed to the statement immediately following the jp instruction. the second example shows an unconditional jp. the statement "jp @00" replaces the contents of the pc with the contents of the register pair 00h and 01h, leaving the value 0120h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 176
jr jump relative jr cc,dst operation: if cc is true, pc  pc + dst if the condition specified by the condition code (cc) is true, the relative address is added to the program counter and control passes to the statement whose address is now in the program counter; otherwise, the instruction following the jr instruction is executed. (see list of condition codes). the range of the relative address is +127, C128, and the original value of the program counter is taken to be the address of the first instruction byte following the jr statement. flags: no flags are affected. format: (1) bytes cycles opcode (hex) addr mode dst cc | opc dst 2 6 ccb ra cc = 0 to f note : in the first byte of the two-byte instruction format, the condition code and the opcode are each four bits. example: given: the carry flag = "1" and label_x = 1ff7h: jr c,label_x  pc = 1ff7h if the carry flag is set (that is, if the condition code is true), the statement "jr c,label_x" will pass control to the statement whose address is now in the pc. otherwise, the program instruction following the jr would be executed. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 177
ld load ld dst,src operation: dst  src the contents of the source are loaded into the destination. the source's contents are unaffected. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src dst | opc src 2 4 rc r im 4 r8 r r src | opc dst 2 4 r9 r r r = 0 t o f opc dst | src 2 4 c7 r lr 4 d 7 i r r opc src dst 3 6 e4 r r 6 e 5 r i r opc dst src 3 6 e6 r im 6 d6 ir im opc src dst 3 6 f5 ir r opc dst | src x 3 6 87 r x [r] opc src | dst x 3 6 97 x [r] r ps031601-0813 p r e l i m i n a r y S3F82NB product specification 178
ld load ld (continued) examples: given: r0 = 01h, r1 = 0ah, register 00h = 01h, register 01h = 20h, register 02h = 02h, loop = 30h, and register 3ah = 0ffh: ld r0,#10h  r0 = 10h ld r0,01h  r0 = 20h, register 01h = 20h ld 01h,r0  register 01h = 01h, r0 = 01h ld r1,@r0  r1 = 20h, r0 = 01h ld @r0,r1  r0 = 01h, r1 = 0ah, register 01h = 0ah ld 00h,01h  register 00h = 20h, register 01h = 20h ld 02h,@00h  register 02h = 20h, register 00h = 01h ld 00h,#0ah  register 00h = 0ah ld @00h,#10h  register 00h = 01h, register 01h = 10h ld @00h,02h  register 00h = 01h, register 01h = 02, register 02h = 02h ld r0,#loop[r1]  r0 = 0ffh, r1 = 0ah ld #loop[r0],r1  register 31h = 0ah, r0 = 01h, r1 = 0ah ps031601-0813 p r e l i m i n a r y S3F82NB product specification 179
ldb load bit ldb dst,src.b ldb dst.b,src operation: dst(0)  src(b) or dst(b)  src(0) the specified bit of the source is loaded into bit zero (lsb) of the destination, or bit zero of the source is loaded into the specified bit of the destination. no other bits of the destination are affected. the source is unaffected. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc dst | b | 0 src 3 6 47 r0 rb opc src | b | 1 dst 3 6 47 rb r0 note : in the second byte of the instruction formats, the destination (or source) address is four bits, the bit address 'b' is three bits, and the lsb address value is one bit in length. examples: given: r0 = 06h and general register 00h = 05h: ldb r0,00h.2  r0 = 07h, register 00h = 05h ldb 00h.0,r0  r0 = 06h, register 00h = 04h in the first example, destination working register r0 contains the value 06h and the source general register 00h the value 05h. the statement "ld r0,00h.2" loads the bit two value of the 00h register into bit zero of the r0 register, leaving the value 07h in register r0. in the second example, 00h is the destination register. the statement "ld 00h.0,r0" loads bit zero of register r0 to the specified bit (bit zero) of the destination register, leaving 04h in general register 00h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 180
ldc/lde load memory ldc/lde dst,src operation: dst  src this instruction loads a byte from program or data memory into a working register or vice-versa. the source values are unaffected. ldc refers to program memory and lde to data memory. the assembler makes 'irr' or 'rr' values an even number for program memory and odd an odd number for data memory. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src 1. opc dst | src 2 10 c3 r irr 2. opc src | dst 2 10 d3 irr r 3. opc dst | src xs 3 12 e7 r xs [rr] 4. opc src | dst xs 3 12 f7 xs [rr] r 5. opc dst | src xl l xl h 4 14 a7 r xl [rr] 6. opc src | dst xl l xl h 4 14 b7 xl [rr] r 7. opc dst | 0000 da l da h 4 14 a7 r da 8. opc src | 0000 da l da h 4 14 b7 da r 9. opc dst | 0001 da l da h 4 14 a7 r da 10. opc src | 0001 da l da h 4 14 b7 da r notes : 1. the source (src) or working register pair [rr] for formats 5 and 6 cannot use register pair 0C1. 2. for formats 3 and 4, the destination address 'xs [rr]' and the source address 'xs [rr]' are each one byte. 3. for formats 5 and 6, the destination address 'xl [rr] and the source address 'xl [rr]' are each two bytes. 4. the da and r source values for formats 7 and 8 are used to address program memory; the second set of values, used in formats 9 and 10, are used to address data memory. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 181
ldc/lde load memory ldc/lde (continued) examples: given: r0 = 11h, r1 = 34h, r2 = 01h, r3 = 04h; program memory locations 0103h = 4fh, 0104h = 1a, 0105h = 6dh, and 1104h = 88h. external data memory locations 0103h = 5fh, 0104h = 2ah, 0105h = 7dh, and 1104h = 98h: ldc r0,@rr2 ; r0  contents of program memory location 0104h ; r0 = 1ah, r2 = 01h, r3 = 04h lde r0,@rr2 ; r0  contents of external data memory location 0104h ; r0 = 2ah, r2 = 01h, r3 = 04h ldc (note) @rr2,r0 ; 11h (contents of r0) is loaded into program memory ; location 0104h (rr2), ; working registers r0, r2, r3  no change lde @rr2,r0 ; 11h (contents of r0) is loaded into external data memory ; location 0104h (rr2), ; working registers r0, r2, r3  no change ldc r0,#01h[rr2] ; r0  contents of program memory location 0105h ; (01h + rr2), ; r0 = 6dh, r2 = 01h, r3 = 04h lde r0,#01h[rr2] ; r0  contents of external data memory location 0105h ; (01h + rr2), r0 = 7dh, r2 = 01h, r3 = 04h ldc (note) #01h[rr2],r0 ; 11h (contents of r0) is loaded into program memory location ; 0105h (01h + 0104h) lde #01h[rr2],r0 ; 11h (contents of r0) is loaded into external data memory ; location 0105h (01h + 0104h) ldc r0,#1000h[rr2] ; r0  contents of program memory location 1104h ; (1000h + 0104h), r0 = 88h, r2 = 01h, r3 = 04h lde r0,#1000h[rr2] ; r0  contents of external data memory location 1104h ; (1000h + 0104h), r0 = 98h, r2 = 01h, r3 = 04h ldc r0,1104h ; r0  contents of program memory location 1104h, r0 = 88h lde r0,1104h ; r0  contents of external data memory location 1104h, ; r0 = 98h ldc (note) 1105h,r0 ; 11h (contents of r0) is loaded into program memory location ; 1105h, (1105h)  11h lde 1105h,r0 ; 11h (contents of r0) is loaded into external data memory ; location 1105h, (1105h)  11h note: these instructions are not supported by masked rom type devices. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 182
ldcd/lded load memory and decrement ldcd/lded dst,src operation: dst  src rr  rr C 1 these instructions are used for user stacks or block transfers of data from program or data memory to the register file. the address of the memory location is specified by a working register pair. the contents of the source location are loaded into the destination location. the memory address is then decremented. the contents of the source are unaffected. ldcd references program memory and lded references external data memory. the assembler makes 'irr' an even number for program memory and an odd number for data memory. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 10 e2 r irr examples: given: r6 = 10h, r7 = 33h, r8 = 12h, program memory location 1033h = 0cdh, and external data memory location 1033h = 0ddh: ldcd r8,@rr6 ; 0cdh (contents of program memory location 1033h) is loaded ; into r8 and rr6 is decremented by one ; r8 = 0cdh, r6 = 10h, r7 = 32h (rr6  rr6 C 1) lded r8,@rr6 ; 0ddh (contents of data memory location 1033h) is loaded ; into r8 and rr6 is decremented by one (rr6  rr6 C 1) ; r8 = 0ddh, r6 = 10h, r7 = 32h ps031601-0813 p r e l i m i n a r y S3F82NB product specification 183
ldci/ldei load memory and increment ldci/ldei dst,src operation: dst  src rr  rr + 1 these instructions are used for user stacks or block transfers of data from program or data memory to the register file. the address of the memory location is specified by a working register pair. the contents of the source location are loaded into the destination location. the memory address is then incremented automatically. the contents of the source are unaffected. ldci refers to program memory and ldei refers to external data memory. the assembler makes 'irr' even for program memory and odd for data memory. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 10 e3 r irr examples: given: r6 = 10h, r7 = 33h, r8 = 12h, program memory locations 1033h = 0cdh and 1034h = 0c5h; external data memory locations 1033h = 0ddh and 1034h = 0d5h: ldci r8,@rr6 ; 0cdh (contents of program memory location 1033h) is loaded ; into r8 and rr6 is incremented by one (rr6  rr6 + 1) ; r8 = 0cdh, r6 = 10h, r7 = 34h ldei r8,@rr6 ; 0ddh (contents of data memory location 1033h) is loaded ; into r8 and rr6 is incremented by one (rr6  rr6 + 1) ; r8 = 0ddh, r6 = 10h, r7 = 34h ps031601-0813 p r e l i m i n a r y S3F82NB product specification 184
ldcpd/ldepd load memory with pre-decrement ldcpd/ ldepd dst,src operation: rr  rr C 1 dst  src these instructions are used for block transfers of data from program or data memory from the register file. the address of the memory location is specified by a working register pair and is first decremented. the contents of the source location are then loaded into the destination location. the contents of the source are unaffected. ldcpd refers to program memory and ldepd refers to external data memory. the assembler makes 'irr' an even number for program memory and an odd number for external data memory. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc src | dst 2 14 f2 irr r examples: given: r0 = 77h, r6 = 30h, and r7 = 00h: ldcpd @rr6,r0 ; (rr6  rr6 C 1) ; 77h (contents of r0) is loaded into program memory location ; 2fffh (3000h C 1h) ; r0 = 77h, r6 = 2fh, r7 = 0ffh ldepd @rr6,r0 ; (rr6  rr6 C 1) ; 77h (contents of r0) is loaded into external data memory ; location 2fffh (3000h C 1h) ; r0 = 77h, r6 = 2fh, r7 = 0ffh ps031601-0813 p r e l i m i n a r y S3F82NB product specification 185
ldcpi/ldepi load memory with pre-increment ldcpi/ ldepi dst,src operation: rr  rr + 1 dst  src these instructions are used for block transfers of data from program or data memory from the register file. the address of the memory location is specified by a working register pair and is first incremented. the contents of the source location are loaded into the destination location. the contents of the source are unaffected. ldcpi refers to program memory and ldepi refers to external data memory. the assembler makes 'irr' an even number for program memory and an odd number for data memory. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc src | dst 2 14 f3 irr r examples: given: r0 = 7fh, r6 = 21h, and r7 = 0ffh: ldcpi @rr6,r0 ; (rr6  rr6 + 1) ; 7fh (contents of r0) is loaded into program memory ; location 2200h (21ffh + 1h) ; r0 = 7fh, r6 = 22h, r7 = 00h ldepi @rr6,r0 ; (rr6  rr6 + 1) ; 7fh (contents of r0) is loaded into external data memory ; location 2200h (21ffh + 1h) ; r0 = 7fh, r6 = 22h, r7 = 00h ps031601-0813 p r e l i m i n a r y S3F82NB product specification 186
ldw load word ldw dst,src operation: dst  src the contents of the source (a word) are loaded into the destination. the contents of the source are unaffected. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc src dst 3 8 c4 rr rr 8 c5 rr ir opc dst src 4 8 c6 rr iml examples: given: r4 = 06h, r5 = 1ch, r6 = 05h, r7 = 02h, register 00h = 1ah, register 01h = 02h, register 02h = 03h, and register 03h = 0fh: ldw rr6,rr4  r6 = 06h, r7 = 1ch, r4 = 06h, r5 = 1ch ldw 00h,02h  register 00h = 03h, register 01h = 0fh, register 02h = 03h, register 03h = 0fh ldw rr2,@r7  r2 = 03h, r3 = 0fh, ldw 04h,@01h  register 04h = 03h, register 05h = 0fh ldw rr6,#1234h  r6 = 12h, r7 = 34h ldw 02h,#0fedh  register 02h = 0fh, register 03h = 0edh in the second example, please note that the statement "ldw 00h,02h" loads the contents of the source word 02h, 03h into the destination word 00h, 01h. this leaves the value 03h in general register 00h and the value 0fh in register 01h. the other examples show how to use the ldw instruction with various addressing modes and formats. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 187
mult multiply (unsigned) mult dst,src operation: dst  dst  src the 8-bit destination operand (even register of the register pair) is multiplied by the source operand (8 bits) and the product (16 bits) is stored in the register pair specified by the destination address. both operands are treated as unsigned integers. flags: c: set if result is  255; cleared otherwise. z: set if the result is "0"; cleared otherwise. s: set if msb of the result is a "1"; cleared otherwise. v: cleared. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc src dst 3 22 84 rr r 22 85 rr ir 22 86 rr im examples: given: register 00h = 20h, register 01h = 03h, register 02h = 09h, register 03h = 06h: mult 00h, 02h  register 00h = 01h, register 01h = 20h, register 02h = 09h mult 00h, @01h  register 00h = 00h, register 01h = 0c0h mult 00h, #30h  register 00h = 06h, register 01h = 00h in the first example, the statement "mult 00h,02h" multiplies the 8-bit destination operand (in the register 00h of the register pair 00h, 01h) by the source register 02h operand (09h). the 16-bit product, 0120h, is stored in the register pair 00h, 01h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 188
next next next operation: pc  @ ip ip  ip + 2 the next instruction is useful when implementing threaded-code languages. the program memory word that is pointed to by the instruction pointer is loaded into the program counter. the instruction pointer is then incremented by two. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 10 0f example: the following diagram shows one example of how to use the next instruction. data 01 10 before after 0045 ip address data 0130 pc 43 44 45 address h address l address h address data memory 130 routine 0043 ip address data 0120 pc 43 44 45 address h address l address h address data memory 120 next ps031601-0813 p r e l i m i n a r y S3F82NB product specification 189
nop no operation nop operation: no action is performed when the cpu executes this instruction. typically, one or more nops are executed in sequence in order to effect a timing delay of variable duration. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 4 ff example: when the instruction nop is encountered in a program, no operation occurs. instead, there is a delay in instruction execution time. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 190
or logical or or dst,src operation: dst  dst or src the source operand is logically ored with the destination operand and the result is stored in the destination. the contents of the source are unaffected. the or operation results in a "1" being stored whenever either of the corresponding bits in the two operands is a "1"; otherwise a "0" is stored. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: always cleared to "0". d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 42 r r 6 43 r lr opc src dst 3 6 44 r r 6 45 r ir opc dst src 3 6 46 r im examples: given: r0 = 15h, r1 = 2ah, r2 = 01h, register 00h = 08h, register 01h = 37h, and register 08h = 8ah: or r0,r1  r0 = 3fh, r1 = 2ah or r0,@r2  r0 = 37h, r2 = 01h, register 01h = 37h or 00h,01h  register 00h = 3fh, register 01h = 37h or 01h,@00h  register 00h = 08h, register 01h = 0bfh or 00h,#02h  register 00h = 0ah in the first example, if working register r0 contains the value 15h and register r1 the value 2ah, the statement "or r0,r1" logical-ors the r0 and r1 register contents and stores the result (3fh) in destination register r0. the other examples show the use of the logical or instruction with the various addressing modes and formats. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 191
pop pop from stack pop dst operation: dst  @sp sp  sp + 1 the contents of the location addressed by the stack pointer are loaded into the destination. the stack pointer is then incremented by one. flags: no flags affected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 8 50 r 8 51 ir examples: given: register 00h = 01h, register 01h = 1bh, sph (0d8h) = 00h, spl (0d9h) = 0fbh, and stack register 0fbh = 55h: pop 00h  register 00h = 55h, sp = 00fch pop @00h  register 00h = 01h, register 01h = 55h, sp = 00fch in the first example, general register 00h contains the value 01h. the statement "pop 00h" loads the contents of location 00fbh (55h) into destination register 00h and then increments the stack pointer by one. register 00h then contains the value 55h and the sp points to location 00fch. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 192
popud pop user stack (decrementing) popud dst,src operation: dst  src ir  ir C 1 this instruction is used for user-defined stacks in the register file. the contents of the register file location addressed by the user stack pointer are loaded into the destination. the user stack pointer is then decremented. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc src dst 3 8 92 r ir example: given: register 00h = 42h (user stack pointer register), register 42h = 6fh, and register 02h = 70h: popud 02h,@00h  register 00h = 41h, register 02h = 6fh, register 42h = 6fh if general register 00h contains the value 42h and register 42h the value 6fh, the statement "popud 02h,@00h" loads the contents of register 42h into the destination register 02h. the user stack pointer is then decremented by one, leaving the value 41h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 193
popui pop user stack (incrementing) popui dst,src operation: dst  src ir  ir + 1 the popui instruction is used for user-defined stacks in the register file. the contents of the register file location addressed by the user stack pointer are loaded into the destination. the user stack pointer is then incremented. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc src dst 3 8 93 r ir example: given: register 00h = 01h and register 01h = 70h: popui 02h,@00h  register 00h = 02h, register 01h = 70h, register 02h = 70h if general register 00h contains the value 01h and register 01h the value 70h, the statement "popui 02h,@00h" loads the value 70h into the destination general register 02h. the user stack pointer (register 00h) is then incremented by one, changing its value from 01h to 02h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 194
push push to stack push src operation: sp  sp C 1 @sp  src a push instruction decrements the stack pointer value and loads the contents of the source (src) into the location addressed by the decremented stack pointer. the operation then adds the new value to the top of the stack. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst opc src 2 8 (internal clock) 70 r 8 (external clock) 8 (internal clock) 8 (external clock) 71 ir examples: given: register 40h = 4fh, register 4fh = 0aah, sph = 00h, and spl = 00h: push 40h  register 40h = 4fh, stack register 0ffh = 4fh, sph = 0ffh, spl = 0ffh push @40h  register 40h = 4fh, register 4fh = 0aah, stack register 0ffh = 0aah, sph = 0ffh, spl = 0ffh in the first example, if the stack pointer contains the value 0000h, and general register 40h the value 4fh, the statement "push 40h" decrements the stack pointer from 0000 to 0ffffh. it then loads the contents of register 40h into location 0ffffh and adds this new value to the top of the stack. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 195
pushud push user stack (decrementing) pushud dst,src operation: ir  ir C 1 dst  src this instruction is used to address user-defined stacks in the register file. pushud decrements the user stack pointer and loads the contents of the source into the register addressed by the decremented stack pointer. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc dst src 3 8 82 ir r example: given: register 00h = 03h, register 01h = 05h, and register 02h = 1ah: pushud @00h,01h  register 00h = 02h, register 01h = 05h, register 02h = 05h if the user stack pointer (register 00h, for example) contains the value 03h, the statement "pushud @00h,01h" decrements the user stack pointer by one, leaving the value 02h. the 01h register value, 05h, is then loaded into the register addressed by the decremented user stack pointer. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 196
pushui push user stack (incrementing) pushui dst,src operation: ir  ir + 1 dst  src this instruction is used for user-defined stacks in the register file. pushui increments the user stack pointer and then loads the contents of the source into the register location addressed by the incremented user stack pointer. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc dst src 3 8 83 ir r example: given: register 00h = 03h, register 01h = 05h, and register 04h = 2ah: pushui @00h,01h  register 00h = 04h, register 01h = 05h, register 04h = 05h if the user stack pointer (register 00h, for example) contains the value 03h, the statement "pushui @00h,01h" increments the user stack pointer by one, leaving the value 04h. the 01h register value, 05h, is then loaded into the location addressed by the incremented user stack pointer. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 197
rcf reset carry flag rcf rcf operation: c  0 the carry flag is cleared to logic zero, regardless of its previous value. flags: c: cleared to "0". no other flags are affected. format: bytes cycles opcode (hex) opc 1 4 cf example: given: c = "1" or "0": the instruction rcf clears the carry flag (c) to logic zero. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 198
ret return ret operation: pc  @sp sp  sp + 2 the ret instruction is normally used to return to the previously executing procedure at the end of a procedure entered by a call instruction. the contents of the location addressed by the stack pointer are popped into the program counter. the next statement that is executed is the one that is addressed by the new program counter value. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 8 (internal stack) af 10 (internal stack) example: given: sp = 00fch, (sp) = 101ah, and pc = 1234: ret  pc = 101ah, sp = 00feh the statement "ret" pops the contents of stack pointer location 00fch (10h) into the high byte of the program counter. the stack pointer then pops the value in location 00feh (1ah) into the pc's low byte and the instruction at location 101ah is executed. the stack pointer now points to memory location 00feh. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 199
rl rotate left rl dst operation: c  dst (7) dst (0)  dst (7) dst (n + 1)  dst (n), n = 0C6 the contents of the destination operand are rotated left one bit position. the initial value of bit 7 is moved to the bit zero (lsb) position and also replaces the carry flag. 70 c flags: c: set if the bit rotated from the most significant bit position (bit 7) was "1". z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: set if arithmetic overflow occurred; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 90 r 4 91 ir examples: given: register 00h = 0aah, register 01h = 02h and register 02h = 17h: rl 00h  register 00h = 55h, c = "1" rl @01h  register 01h = 02h, register 02h = 2eh, c = "0" in the first example, if general register 00h contains the value 0aah (10101010b), the statement "rl 00h" rotates the 0aah value left one bit position, leaving the new value 55h (01010101b) and setting the carry and overflow flags. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 200
rlc rotate left through carry rlc dst operation: dst (0)  c c  dst (7) dst (n + 1)  dst (n), n = 0C6 the contents of the destination operand with the carry flag are rotated left one bit position. the initial value of bit 7 replaces the carry flag (c); the initial value of the carry flag replaces bit zero. 70 c flags: c: set if the bit rotated from the most significant bit position (bit 7) was "1". z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 10 r 4 11 ir examples: given: register 00h = 0aah, register 01h = 02h, and register 02h = 17h, c = "0": rlc 00h  register 00h = 54h, c = "1" rlc @01h  register 01h = 02h, register 02h = 2eh, c = "0" in the first example, if general register 00h has the value 0aah (10101010b), the statement "rlc 00h" rotates 0aah one bit position to the left. the initial value of bit 7 sets the carry flag and the initial value of the c flag replaces bit zero of register 00h, leaving the value 55h (01010101b). the msb of register 00h resets the carry flag to "1" and sets the overflow flag. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 201
rr rotate right rr dst operation: c  dst (0) dst (7)  dst (0) dst (n  dst (n + 1), n = 0C6 the contents of the destination operand are rotated right one bit position. the initial value of bit zero (lsb) is moved to bit 7 (msb) and also replaces the carry flag (c). 70 c flags: c: set if the bit rotated from the least significant bit position (bit zero) was "1". z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 e0 r 4 e1 ir examples: given: register 00h = 31h, register 01h = 02h, and register 02h = 17h: rr 00h  register 00h = 98h, c = "1" rr @01h  register 01h = 02h, register 02h = 8bh, c = "1" in the first example, if general register 00h contains the value 31h (00110001b), the statement "rr 00h" rotates this value one bit position to the right. the initial value of bit zero is moved to bit 7, leaving the new value 98h (10011000b) in the destination register. the initial bit zero also resets the c flag to "1" and the sign flag and overflow flag are also set to "1". ps031601-0813 p r e l i m i n a r y S3F82NB product specification 202
rrc rotate right through carry rrc dst operation: dst (7)  c c  dst (0) dst (n)  dst (n + 1), n = 0C6 the contents of the destination operand and the carry flag are rotated right one bit position. the initial value of bit zero (lsb) replaces the carry flag; the initial value of the carry flag replaces bit 7 (msb). 70 c flags: c: set if the bit rotated from the least significant bit position (bit zero) was "1". z: set if the result is "0" cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: set if arithmetic overflow occurred, that is, if the sign of the destination changed during rotation; cleared otherwise. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 c0 r 4 c1 ir examples: given: register 00h = 55h, register 01h = 02h, register 02h = 17h, and c = "0": rrc 00h  register 00h = 2ah, c = "1" rrc @01h  register 01h = 02h, register 02h = 0bh, c = "1" in the first example, if general register 00h contains the value 55h (01010101b), the statement "rrc 00h" rotates this value one bit position to the right. the initial value of bit zero ("1") replaces the carry flag and the initial value of the c flag ("1") replaces bit 7. this leaves the new value 2ah (00101010b) in destination register 00h. the sign flag and overflow flag are both cleared to "0". ps031601-0813 p r e l i m i n a r y S3F82NB product specification 203
sb0 select bank 0 sb0 operation: bank  0 the sb0 instruction clears the bank address flag in the flags register (flags.0) to logic zero, selecting bank 0 register addressing in the set 1 area of the register file. flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 4 4f example: the statement sb0 clears flags.0 to "0", selecting bank 0 register addressing. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 204
sb1 select bank 1 sb1 operation: bank  1 the sb1 instruction sets the bank address flag in the flags register (flags.0) to logic one, selecting bank 1 register addressing in the set 1 area of the register file. (bank 1 is not implemented in some s3c8-series microcontrollers.) flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 4 5f example: the statement sb1 sets flags.0 to "1", selecting bank 1 register addressing, if implemented. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 205
sbc subtract with carry sbc dst,src operation: dst  dst C src C c the source operand, along with the current value of the carry flag, is subtracted from the destination operand and the result is stored in the destination. the contents of the source are unaffected. subtraction is performed by adding the two's-complement of the source operand to the destination operand. in multiple precision arithmetic, this instruction permits the carry ("borrow") from the subtraction of the low-order operands to be subtracted from the subtraction of high-order operands. flags: c: set if a borrow occurred (src  dst); cleared otherwise. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurred, that is, if the operands were of opposite sign and the sign of the result is the same as the sign of the source; cleared otherwise. d: always set to "1". h: cleared if there is a carry from the most significant bit of the low-order four bits of the result; set otherwise, indicating a "borrow". format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 32 r r 6 33 r lr opc src dst 3 6 34 r r 6 35 r ir opc dst src 3 6 36 r im examples: given: r1 = 10h, r2 = 03h, c = "1", register 01h = 20h, register 02h = 03h, and register 03h = 0ah: sbc r1,r2  r1 = 0ch, r2 = 03h sbc r1,@r2  r1 = 05h, r2 = 03h, register 03h = 0ah sbc 01h,02h  register 01h = 1ch, register 02h = 03h sbc 01h,@02h  register 01h = 15h,register 02h = 03h, register 03h = 0ah sbc 01h,#8ah  register 01h = 5h; c, s, and v = "1" in the first example, if working register r1 contains the value 10h and register r2 the value 03h, the statement "sbc r1,r2" subtracts the source value (03h) and the c flag value ("1") from the destination (10h) and then stores the result (0ch) in register r1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 206
scf set carry flag scf operation: c  1 the carry flag (c) is set to logic one, regardless of its previous value. flags: c: set to "1". no other flags are affected. format: bytes cycles opcode (hex) opc 1 4 df example: the statement scf sets the carry flag to logic one. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 207
sra shift right arithmetic sra dst operation: dst (7)  dst (7) c  dst (0) dst (n)  dst (n + 1), n = 0C6 an arithmetic shift-right of one bit position is performed on the destination operand. bit zero (the lsb) replaces the carry flag. the value of bit 7 (the sign bit) is unchanged and is shifted into bit position 6. 70 c 6 flags: c: set if the bit shifted from the lsb position (bit zero) was "1". z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: always cleared to "0". d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 d0 r 4 d1 ir examples: given: register 00h = 9ah, register 02h = 03h, register 03h = 0bch, and c = "1": sra 00h  register 00h = 0cd, c = "0" sra @02h  register 02h = 03h, register 03h = 0deh, c = "0" in the first example, if general register 00h contains the value 9ah (10011010b), the statement "sra 00h" shifts the bit values in register 00h right one bit position. bit zero ("0") clears the c flag and bit 7 ("1") is then shifted into the bit 6 position (bit 7 remains unchanged). this leaves the value 0cdh (11001101b) in destination register 00h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 208
srp/srp0/srp1 set register pointer srp src srp0 src srp1 src operation: if src (1) = 1 and src (0) = 0 then: rp0 (3C7)  src (3C7) if src (1) = 0 and src (0) = 1 then: rp1 (3C7)  src (3C7) if src (1) = 0 and src (0) = 0 then: rp0 (4C7)  src (4C7), rp0 (3)  0 rp1 (4C7)  src (4C7), rp1 (3)  1 the source data bits one and zero (lsb) determine whether to write one or both of the register pointers, rp0 and rp1. bits 3C7 of the selected register pointer are written unless both register pointers are selected. rp0.3 is then cleared to logic zero and rp1.3 is set to logic one. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode src opc src 2 4 31 im examples: the statement srp #40h sets register pointer 0 (rp0) at location 0d6h to 40h and register pointer 1 (rp1) at location 0d7h to 48h. the statement "srp0 #50h" sets rp0 to 50h, and the statement "srp1 #68h" sets rp1 to 68h. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 209
stop stop operation stop operation: the stop instruction stops the both the cpu clock and system clock and causes the microcontroller to enter stop mode. during stop mode, the contents of on-chip cpu registers, peripheral registers, and i/o port control and data registers are retained. stop mode can be released by an external reset operation or by external interrupts. for the reset operation, the reset pin must be held to low level until the required oscillation stabilization interval has elapsed. flags: no flags are affected. format: bytes cycles opcode (hex) addr mode dst src opc 1 4 7f C C example: the statement stop halts all microcontroller operations. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 210
sub subtract sub dst,src operation: dst  dst C src the source operand is subtracted from the destination operand and the result is stored in the destination. the contents of the source are unaffected. subtraction is performed by adding the two's complement of the source operand to the destination operand. flags: c: set if a "borrow" occurred; cleared otherwise. z: set if the result is "0"; cleared otherwise. s: set if the result is negative; cleared otherwise. v: set if arithmetic overflow occurred, that is, if the operands were of opposite signs and the sign of the result is of the same as the sign of the source operand; cleared otherwise. d: always set to "1". h: cleared if there is a carry from the most significant bit of the low-order four bits of the result; set otherwise indicating a "borrow". format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 22 r r 6 23 r lr opc src dst 3 6 24 r r 6 25 r ir opc dst src 3 6 26 r im examples: given: r1 = 12h, r2 = 03h, register 01h = 21h, register 02h = 03h, register 03h = 0ah: sub r1,r2  r1 = 0fh, r2 = 03h sub r1,@r2  r1 = 08h, r2 = 03h sub 01h,02h  register 01h = 1eh, register 02h = 03h sub 01h,@02h  register 01h = 17h, register 02h = 03h sub 01h,#90h  register 01h = 91h; c, s, and v = "1" sub 01h,#65h  register 01h = 0bch; c and s = "1", v = "0" in the first example, if working register r1 contains the value 12h and if register r2 contains the value 03h, the statement "sub r1,r2" subtracts the source value (03h) from the destination value (12h) and stores the result (0fh) in destination register r1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 211
swap swap nibbles swap dst operation: dst (0 C 3)  dst (4 C 7) the contents of the lower four bits and upper four bits of the destination operand are swapped. 70 4 3 flags: c: undefined. z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: undefined. d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst opc dst 2 4 f0 r 4 f1 ir examples: given: register 00h = 3eh, register 02h = 03h, and register 03h = 0a4h: swap 00h  register 00h = 0e3h swap @02h  register 02h = 03h, register 03h = 4ah in the first example, if general register 00h contains the value 3eh (00111110b), the statement "swap 00h" swaps the lower and upper four bits (nibbles) in the 00h register, leaving the value 0e3h (11100011b). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 212
tcm test complement under mask tcm dst,src operation: (not dst) and src this instruction tests selected bits in the destination operand for a logic one value. the bits to be tested are specified by setting a "1" bit in the corresponding position of the source operand (mask). the tcm statement complements the destination operand, which is then anded with the source mask. the zero (z) flag can then be checked to determine the result. the destination and source operands are unaffected. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: always cleared to "0". d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 62 r r 6 63 r lr opc src dst 3 6 64 r r 6 65 r ir opc dst src 3 6 66 r im examples: given: r0 = 0c7h, r1 = 02h, r2 = 12h, register 00h = 2bh, register 01h = 02h, and register 02h = 23h: tcm r0,r1  r0 = 0c7h, r1 = 02h, z = "1" tcm r0,@r1  r0 = 0c7h, r1 = 02h, register 02h = 23h, z = "0" tcm 00h,01h  register 00h = 2bh, register 01h = 02h, z = "1" tcm 00h,@01h  register 00h = 2bh, register 01h = 02h, register 02h = 23h, z = "1" tcm 00h,#34  register 00h = 2bh, z = "0" in the first example, if working register r0 contains the value 0c7h (11000111b) and register r1 the value 02h (00000010b), the statement "tcm r0,r1" tests bit one in the destination register for a "1" value. because the mask value corresponds to the test bit, the z flag is set to logic one and can be tested to determine the result of the tcm operation. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 213
tm test under mask tm dst,src operation: dst and src this instruction tests selected bits in the destination operand for a logic zero value. the bits to be tested are specified by setting a "1" bit in the corresponding position of the source operand (mask), which is anded with the destination operand. the zero (z) flag can then be checked to determine the result. the destination and source operands are unaffected. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: always reset to "0". d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 72 r r 6 73 r lr opc src dst 3 6 74 r r 6 75 r ir opc dst src 3 6 76 r im examples: given: r0 = 0c7h, r1 = 02h, r2 = 18h, register 00h = 2bh, register 01h = 02h, and register 02h = 23h: tm r0,r1  r0 = 0c7h, r1 = 02h, z = "0" tm r0,@r1  r0 = 0c7h, r1 = 02h, register 02h = 23h, z = "0" tm 00h,01h  register 00h = 2bh, register 01h = 02h, z = "0" tm 00h,@01h  register 00h = 2bh, register 01h = 02h, register 02h = 23h, z = "0" tm 00h,#54h  register 00h = 2bh, z = "1" in the first example, if working register r0 contains the value 0c7h (11000111b) and register r1 the value 02h (00000010b), the statement "tm r0,r1" tests bit one in the destination register for a "0" value. because the mask value does not match the test bit, the z flag is cleared to logic zero and can be tested to determine the result of the tm operation. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 214
wfi wait for interrupt wfi operation: the cpu is effectively halted until an interrupt occurs, except that dma transfers can still take place during this wait state. the wfi status can be released by an internal interrupt, including a fast interrupt . flags: no flags are affected. format: bytes cycles opcode (hex) opc 1 4n 3f ( n = 1, 2, 3, ) example: the following sample program structure shows the sequence of operations that follow a "wfi" statement: ei wfi (next instruction) main program . . . . . . interrupt occurs interrupt service routine . . . clear interrupt flag iret service routine completed (enable global interrupt) (wait for interrupt) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 215
xor logical exclusive or xor dst,src operation: dst  dst xor src the source operand is logically exclusive-ored with the destination operand and the result is stored in the destination. the exclusive-or operation results in a "1" bit being stored whenever the corresponding bits in the operands are different; otherwise, a "0" bit is stored. flags: c: unaffected. z: set if the result is "0"; cleared otherwise. s: set if the result bit 7 is set; cleared otherwise. v: always reset to "0". d: unaffected. h: unaffected. format: bytes cycles opcode (hex) addr mode dst src opc dst | src 2 4 b2 r r 6 b3 r lr opc src dst 3 6 b4 r r 6 b5 r ir opc dst src 3 6 b6 r im examples: given: r0 = 0c7h, r1 = 02h, r2 = 18h, register 00h = 2bh, register 01h = 02h, and register 02h = 23h: xor r0,r1  r0 = 0c5h, r1 = 02h xor r0,@r1  r0 = 0e4h, r1 = 02h, register 02h = 23h xor 00h,01h  register 00h = 29h, register 01h = 02h xor 00h,@01h  register 00h = 08h, register 01h = 02h, register 02h = 23h xor 00h,#54h  register 00h = 7fh in the first example, if working register r0 contains the value 0c7h and if register r1 contains the value 02h, the statement "xor r0,r1" logically exclusive-ors the r1 value with the r0 value and stores the result (0c5h) in the destination register r0. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 216
7 clock circuit overview the S3F82NB microcontroller has two oscillator circuits: a main clock and a sub clock circuit. the cpu and peripheral hardware operate on the system clock frequency supplied through these circuits. the maximum cpu clock frequency of S3F82NB is determined by clkcon register settings. system clock circuit the system clock circuit has the following components: external crystal, ceramic resonator, rc oscillation source, or an external clock source oscillator stop and wake-up functions programmable frequency divider for the cpu clock (fxx divided by 1, 2, 8, or 16) system clock control register, clkcon oscillator control register, osccon and stop control register, stpcon cpu clock notation in this document, the following notation is used for descriptions of the cpu clock; fx: main clock fxt: sub clock fxx: selected system clock ps031601-0813 p r e l i m i n a r y S3F82NB product specification 217
main oscillator circuits x in x out figure 7-1. crystal/ceramic oscillator (f x ) x in x out figure 7-2. external oscillator (f x ) x in x out r figure 7-3. rc oscillator (f x ) sub oscillator circuits xt in xt out 32.768 khz figure 7-4. crystal oscillator (fxt) xt in xt out figure 7-5. external oscillator (fxt) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 218
clock status during power-down modes the two power-down modes, stop mode and idle mode, affect the system clock as follows: in stop mode, the main oscillator is halted. stop mode is released, and the oscillator is started, by a reset operation or an external interrupt (with rc delay noise filter), and can be released by internal interrupt too when the sub-system oscillator is running and watch timer is operating with sub-system clock. in idle mode, the internal clock signal is gated to the cpu, but not to interrupt structure, timers and timer/ counters. idle mode is released by a reset or by an external or internal interrupt. 1/1-1/4096 frequency dividing circuit stop release main-system oscillator circuit selector 1 f x f x t stop sub-system oscillator circuit int osccon.0 osccon.3 osccon.2 selector 2 stpcon stop osc inst. f xx clkcon.4-.3 cpu clock stop watch timer basic timer timer/counters 0, 1/a watch timer lcd controller sio a/d converter comparator lvr idle instruction 1/1 1/16 1/2 1/8 lcd controller figure 7-6. system clock circuit diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 219
system clock control register (clkcon) the system clock control register, clkcon, is located in the set 1, address d4h. it is read/write addressable and has the following functions: oscillator frequency divide-by value after the main oscillator is activated, and the fxx/16 (the slowest clock speed) is selected as the cpu clock. if necessary, you can then increase the cpu clock speed fxx/8, fxx/2, or fxx/1. system clock control register (clkcon) d4h, set 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb not used (must keep always 0) not used (must keep always 0) divide-by selection bits for cpu clock frequency: 00 = f xx /16 01 = f xx /8 10 = f xx /2 11 = f xx /1 oscillator irq wake-up function bit: 0 = enable irq for main wake-up in power down mode 1 = disable irq for main wake-up in power down mode note: after a reset, the slowest clock (divided by 16) is selected as the system clock. to select faster speed, load the appropriate values to clkcon.3-.4. figure 7-7. system clock control register (clkcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 220
oscillator control register (osccon) the oscillator control register, osccon, is located in set 1, bank 0, at address fah. it is read/write addressable and has the following functions: system clock selection main oscillator control sub oscillator control osccon.0 register settings select main clock or sub clock as system clock. after a reset, main clock is selected for system clock because the reset value of osccon.0 is "0". the main oscillator can be stopped or run by setting osccon.3. the sub oscillator can be stopped or run by setting osccon.2. oscillator control register (osccon) fah, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb main system oscillator control bit: 0 = main oscillator run 1 = main oscillator stop sub system oscillator control bit: 0 = sub oscillator run 1 = sub oscillator stop not used for S3F82NB system clock selection bit: 0 = main oscillator select 1 = sub oscillator select not used for S3F82NB figure 7-8. oscillator control register (osccon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 221
stop control register (stpcon) the stop control register, stpcon, is located in the bank 0 of set1, address f5h. it is read/write addressable and has the following functions: enable/disable stop instruction after a reset, the stop instruction is disabled, because the value of stpcon is "other values". if necessary, you can use the stop instruction by setting the value of stpcon to "10100101b". stop control register (stpcon) f5h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb stop control bits: other values = disable stop instruction 10100101 = enable stop instruction note: before executing the stop instruction, set the stpcon register as "10100101b". otherwise the stop instruction will not be executed and reset will be generated. figure 7-9. stop control register (stpcon)   programming tip how to use stop instruction this example shows how to go stop mode when a main clock is selected as the system clock. ld stopcon,#1010010b ; enable stop instruction stop ; enter stop mode nop nop nop ; release stop mode ld stopcon,#00000000b ; disable stop instruction ps031601-0813 p r e l i m i n a r y S3F82NB product specification 222
switching the cpu clock data loading in the oscillator control register, osccon, determine whether a main or a sub clock is selected as the cpu clock, and also how this frequency is to be divided by setting clkcon. this makes it possible to switch dynamically between main and sub clocks and to modify operating frequencies. osccon.0 selects the main clock (fx) or the sub clock (fxt) for the cpu clock. osccon .3 start or stop main clock oscillation and osccon.2 start or stop sub clock oscillation. clkcon.4C.3 controls the frequency divider circuit, and divides the selected fxx clock by 1, 2, 8 and 16. if the sub clock (fxt) is selected for system clock, the clkcon.4C.3 must be set to 11. for example, you are using the default cpu clock (normal operating mode and a main clock of fx/16) and you want to switch from the fx clock to a sub clock and to stop the main clock. to do this, you need to set clkcon.4- .3 to "11", osccon.0 to 1, and osccon.3 to 1 by turns. this switches the clock from fx to fxt and stops main clock oscillation. the following steps must be taken to switch from a sub clock to the main clock: first, set osccon.3 to 0 to enable main clock oscillation. then, after a certain number of machine cycles have elapsed, select the main clock by setting osccon.0 to 0.   programming tip switching the cpu clock 1. this example shows how to change from the main clock to the sub clock: ma2sub or clkcon,#18h ; non-divided clock for system clock ld osccon,#01h ; switches to the sub clock call dly16 ; delay 16 ms or osccon,#08h ; stop the main clock oscillation ret 2. this example shows how to change from sub clock to main clock: sub2ma and osccon,#07h ; start the main clock oscillation call dly16 ; delay 16 ms and osccon,#06h ; switch to the main clock ret dly16 srp #0c0h ld r0,#20h del nop djnz r0,del ret ps031601-0813 p r e l i m i n a r y S3F82NB product specification 223
8 reset and power-down system reset overview during a power-on reset, the voltage at v dd goes to high level and the nreset pin is forced to low level. the nreset signal is input through a schmitt trigger circuit where it is then synchronized with the cpu clock. this procedure brings the S3F82NB into a known operating status. to allow time for internal cpu clock oscillation to stabilize, the nreset pin must be held to low level for a minimum time interval after the power supply comes within tolerance. the minimum required time of a reset operation for oscillation stabilization is 1 millisecond. whenever a reset occurs during normal operation (that is, when both v dd and nreset are high level), the nreset pin is forced low level and the reset operation starts. all system and peripheral control registers are then reset to their default hardware values in summary, the following sequence of events occurs during a reset operation: all interrupt is disabled. the watchdog function (basic timer) is enabled. ports 0-10 and set to input mode, and all pull-up resistors are disabled for the i/o port. peripheral control and data register settings are disabled and reset to their default hardware values. the program counter (pc) is loaded with the program reset address in the rom, 0100h. when the programmed oscillation stabilization time interval has elapsed, the instruction stored in rom location 0100h (and 0101h) is fetched and executed at normal mode by smart option. the reset address at rom can be changed by smart option in the S3F82NB (full-flash device). refer to "the chapter 18. embedded flash memory interface" for more detailed contents. normal mode reset operation in normal mode, the test pin is tied to v ss . a reset enables access to the 64-kbyte on-chip rom. (the external interface is not automatically configured). note to program the duration of the oscillation stabilization interval, you make the appropriate settings to the basic timer control register, btcon, before entering stop mode. also, if you do not want to use the basic timer watchdog function (which causes a system reset if a basic timer counter overflow occurs), you can disable it by writing "1010b" to the upper nibble of btcon. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 224
hardware reset values table 8-1, 8-2, 8-3, 8-4 list the reset values for cpu and system registers, peripheral control registers, and peripheral data registers following a reset operation. the following notation is used to represent reset values: a "1" or a "0" shows the reset bit value as logic one or logic zero, respectively. an "x" means that the bit value is undefined after a reset. a dash ("C") means that the bit is either not used or not mapped, but read 0 is the bit value. table 8-1. S3F82NB set 1 register and values after reset register name mnemonic address bit values after reset dechex7654 3 2 10 locations d0hCd2h are not mapped. basic timer control register btcon 211 d3h 0000 0 0 00 system clock control register clkcon 212 d4h 0CC0 0 C CC system flags register flags 213 d5h x x x x x x 0 0 register pointer 0 rp0 214 d6h 1100 0 C CC register pointer 1 rp1 215 d7h 1100 1 C CC stack pointer (high byte) sph 216 d8h x x x x x x x x stack pointer (low byte) spl 217 d9h x x x x x x x x instruction pointer (high byte) iph 218 dah x x x x x x x x instruction pointer (low byte) ipl 219 dbh x x x x x x x x interrupt request register irq 220 dch 0000 0 0 00 interrupt mask register imr 221 ddh x x x x x x x x system mode register sym 222 deh 0 C C x x x 0 0 register page pointer pp 223 dfh 0000 0 0 00 notes: 1. an 'x' means that the bit value is undefined following reset. 2. a dash ('-') means that the bit is neither used nor mapped, but the bit is read as 0. table 8-2. S3F82NB page15 register and values after reset register name mnemonic address bit values after reset dec hex 7 6 5 4 3 2 1 0 reset source indicating register resetid 176 b0h refer to the page 4-51. notes: 1. an 'x' means that the bit value is undefined following reset. 2. a dash ('C') means that the bit is neither used nor mapped, but the bit is read as 0. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 225
table 8-3. S3F82NB set 1, bank 0 register and values after reset register name mnemonic address bit values after reset dec hex 7 6 5 4 3 2 1 0 port group 0 control register pg0con 208 d0h 0 0 0 0 0 0 0 0 port group 1 control register pg1con 209 d1h 0 0 0 0 0 0 0 0 port 6 control register p6con 210 d2h C C 0 0 0 0 0 0 a/d converter data register (high byte) addatah 224 e0h x x x x x x x x a/d converter data register (low byte) addatal 225 e1h C C C C C C x x a/d converter control register adcon 226 e2h C 0 0 0 0 0 0 0 timer 0 counter register t0cnt 227 e3h 0 0 0 0 0 0 0 0 timer 0 data register t0data 228 e4h 1 1 1 1 1 1 1 1 timer 0 control register t0con 229 e5h 0 0 0 0 0 0 0 C timer b counter register tbcnt 230 e6h 0 0 0 0 0 0 0 0 timer a counter register tacnt 231 e7h 0 0 0 0 0 0 0 0 timer b data register tbdata 232 e8h 1 1 1 1 1 1 1 1 timer a data register tadata 233 e9h 1 1 1 1 1 1 1 1 timer b control register tbcon 234 eah 0 0 0 C C 0 0 C timer 1/a control register tacon 235 ebh 0 0 0 0 0 0 0 0 timer interrupt pending register tintpnd 236 ech C C C 0 0 0 0 0 timer interrupt control register tintcon 237 edh C C C 0 0 0 0 0 watch timer control register wtcon 238 eeh 0 0 0 0 0 0 0 0 lcd control register lcon 239 efh 0 0 0 0 0 C C 0 lcd mode register lmod 240 f0h 0 0 0 0 0 C C C comparator control register cmpcon 241 f1h 0 0 0 C 0 0 0 0 comparator result register cmpreg 242 f2h C C C C C 0 0 0 sio control register siocon 243 f3h 0 0 0 0 0 0 0 0 sio data register siodata 244 f4h 0 0 0 0 0 0 0 0 sio pre-scaler register siops 245 f5h 0 0 0 0 0 0 0 0 flash memory sector address register (high byte) fmsech 246 f6h 0 0 0 0 0 0 0 0 flash memory sector address register (low byte) fmsecl 247 f7h 0 0 0 0 0 0 0 0 flash memory user programming enable register fmusr 248 f8h 0 0 0 0 0 0 0 0 flash memory control register fmcon 249 f9h 0 0 0 0 0 C C 0 oscillator control register osccon 250 fah C C C C 0 0 C 0 stop control register stpcon 251 fbh 0 0 0 0 0 0 0 0 location fch is not mapped. basic timer counter btcnt 253 fdh 0 0 0 0 0 0 0 0 location feh is not mapped. interrupt priority register ipr 255 ffh x x x x x x x x notes: 1. an 'x' means that the bit value is undefined following reset. 2. a dash ('C') means that the bit is neither used nor mapped, but the bit is read as 0. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 226
table 8-4. S3F82NB set 1, bank 1 register and values after reset register name mnemonic address bit values after reset dec hex 7 6 5 4 3 2 1 0 port 4 control register (high byte) p4conh 208 d0h 0 0 0 0 0 0 0 0 port 4 control register (low byte) p4conl 209 d1h 0 0 0 0 0 0 0 0 port 4 pull-up resistor enable register p4pur 210 d2h 0 0 0 0 0 0 0 0 port 0 control register (high byte) p0conh 224 e0h 0 0 0 0 0 0 0 0 port 0 control register (low byte) p0conl 225 e1h 0 0 0 0 0 0 0 0 port 0 pull-up resistor enable register p0pur 226 e2h 0 0 0 0 0 0 0 0 alternative function selection register afsel 227 e3h C C C C C C 0 0 port 1 control register (high byte) p1conh 228 e4h 0 0 0 0 0 0 0 0 port 1 control register (low byte) p1conl 229 e5h 0 0 0 0 0 0 0 0 port 1 pull-up resistor enable register p1pur 230 e6h 0 0 0 0 0 0 0 0 port 1 interrupt pending register p1pnd 231 e7h 0 0 0 0 0 0 0 0 port 1 interrupt control register (high byte) p1inth 232 e8h 0 0 0 0 0 0 0 0 port 1 interrupt control register (low byte) p1intl 233 e9h 0 0 0 0 0 0 0 0 port 2 control register (high byte) p2conh 234 eah 0 0 0 0 0 0 0 0 port 2 control register (low byte) p2conl 235 ebh 0 0 0 0 0 0 0 0 port 2 pull-up resistor enable register p2pur 236 ech 0 0 0 0 0 0 0 0 port 3 pull-up resistor enable register p3pur 237 edh C C 0 0 0 0 0 0 port 3 control register (high byte) p3conh 238 eeh 0 0 0 0 0 0 0 0 port 3 control register (low byte) p3conl 239 efh 0 0 0 0 0 0 0 0 port 0 data register p0 240 f0h 0 0 0 0 0 0 0 0 port 1 data register p1 241 f1h 0 0 0 0 0 0 0 0 port 2 data register p2 242 f2h 0 0 0 0 0 0 0 0 port 3 data register p3 243 f3h 0 0 0 0 0 0 0 0 port 4 data register p4 244 f4h 0 0 0 0 0 0 0 0 port 5 data register p5 245 f5h 0 0 0 0 0 0 0 0 port 6 data register p6 246 f6h C C C C C 0 0 0 port 7 data register p7 247 f7h 0 0 0 0 0 0 0 0 port 8 data register p8 248 f8h 0 0 0 0 0 0 0 0 port 9 data register p9 249 f9h 0 0 0 0 0 0 0 0 port 10 data register p10 250 fah 0 0 0 0 0 0 0 0 port 5 interrupt control register p5int 251 fbh 0 0 0 0 0 0 0 0 port 5 interrupt pending register p5pnd 252 fch 0 0 0 0 C C C C port 5 pull-up resistor enable register p5pur 253 fdh 0 0 0 0 0 0 0 0 port 5 control register (high byte) p5conh 254 feh 0 0 0 0 0 0 0 0 port 5 control register (low byte) p5conl 255 ffh 0 0 0 0 0 0 0 0 notes: 1. an 'x' means that the bit value is undefined following reset. 2. a dash ('C') means that the bit is neither used nor mapped, but the bit is read as 0. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 227
power-down modes stop mode stop mode is invoked by the instruction stop (opcode 7fh). in stop mode, the operation of the cpu and all peripherals is halted. that is, the on-chip main oscillator stops and the supply current is reduced to less than 3  a. all system functions stop when the clock freezes, but data stored in the internal register file is retained. stop mode can be released in one of two ways: by a reset or by interrupts, for more details see figure 7-6. note do not use stop mode if you are using an external clock source because x in or xt in input must be restricted internally to v ss to reduce current leakage. using nreset to release stop mode stop mode is released when the nreset signal is released and returns to high level: all system and peripheral control registers are reset to their default hardware values and the contents of all data registers are retained. a reset operation automatically selects a slow clock fxx/16 because clkcon.3 and clkcon.4 are cleared to 00b. after the programmed oscillation stabilization interval has elapsed, the cpu starts the system initialization routine by fetching the program instruction stored in rom location 0100h (and 0101h) using an external interrupt to release stop mode external interrupts with an rc-delay noise filter circuit can be used to release stop mode. which interrupt you can use to release stop mode in a given situation depends on the microcontrollers current internal operating mode. the external interrupts in the S3F82NB interrupt structure that can be used to release stop mode are: external interrupts p1.0Cp1.7, p5.4Cp5.7 (int0Cint11) please note the following conditions for stop mode release: if you release stop mode using an external interrupt, the current values in system and peripheral control registers are unchanged except stpcon register. if you use an internal or external interrupt for stop mode release, you can also program the duration of the oscillation stabilization interval. to do this, you must make the appropriate control and clock settings before entering stop mode. when the stop mode is released by external interrupt, the clkcon.4 and clkcon.3 bit-pair setting remains unchanged and the currently selected clock value is used. the external interrupt is serviced when the stop mode release occurs. following the iret from the service routine, the instruction immediately following the one that initiated stop mode is executed. using an internal interrupt to release stop mode activate any enabled interrupt, causing stop mode to be released. other things are same as using external interrupt. how to enter into stop mode handling stpcon register then writing stop instruction (keep the order). ld stpcon,#10100101b stop nop nop nop ps031601-0813 p r e l i m i n a r y S3F82NB product specification 228
idle mode idle mode is invoked by the instruction idle (opcode 6fh). in idle mode, cpu operations are halted while some peripherals remain active. during idle mode, the internal clock signal is gated away from the cpu, but all peripherals timers remain active. port pins retain the mode (input or output) they had at the time idle mode was entered. there are two ways to release idle mode: 1. execute a reset. all system and peripheral control registers are reset to their default values and the contents of all data registers are retained. the reset automatically selects the slow clock fxx/16 because clkcon.4 and clkcon.3 are cleared to 00b. if interrupts are masked, a reset is the only way to release idle mode. 2. activate any enabled interrupt, causing idle mode to be released. when you use an interrupt to release idle mode, the clkcon.4 and clkcon.3 register values remain unchanged, and the currently selected clock value is used. the interrupt is then serviced. when the return-from-interrupt (iret) occurs, the instruction immediately following the one that initiated idle mode is executed. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 229
9 i/o ports overview the S3F82NB microcontroller has eleven bit-programmable i/o ports, p0Cp10. the port 6 is a 3-bit port and the others are 8-bit ports. this gives a total of 83 i/o pins. each port can be flexibly configured to meet application design requirements. the cpu accesses ports by directly writing or reading port registers. no special i/o instructions are required. table 9-1 gives you a general overview of the S3F82NB i/o port functions. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 230
table 9-1. S3F82NB port configuration overview port configuration options 0 1-bit programmable i/o port. input (p0.0 and p0.1 are schmitt trigger input) or push-pull, open-drain output mode selected by software; software assignable pull-ups. alternately p0.0Cp0.7 can be used as t1clk/ad0, t0clk/ad1, t1out/t1pwm/t1cap/ad2, t0out/t0pwm/t0cap/ad3, ad4Cad7. 1 1-bit programmable i/o port. schmitt trigger input or push-pull, open-drain output mode selected by software; software assignable pull-ups. p1.0Cp1.7 can be used as inputs for external interrupts int0Cint7 (with noise filter, interrupt enable and pending control). the p1.0 is configured as one of the p1.0/int0 and av ref by smart option. alternately p1.0Cp1.7 can be used as buz, si, so, sck. 2 1-bit programmable i/o port. input or push-pull, open-drain output mode selected by software; software assignable pull-ups. alternatively p2.0-p2.7 can be used as outputs for lcd seg. 3 1-bit programmable i/o port. input or push-pull, open-drain output mode selected by software; software assignable pull-ups. alternatively p3.0-p3.7 can be used as outputs for lcd seg. 4 1-bit programmable i/o port. input or push-pull, open-drain output mode selected by software; software assignable pull-ups. alternatively p4.0-p4.7 can be used as outputs for lcd seg. 5 1-bit programmable i/o port. input (p5.4Cp5.7 are schmitt trigger input) or push-pull, open-drain output mode selected by software; software assignable pull-ups. p5.4Cp5.7 can be used as inputs for external interrupts int8Cint11 (with noise filter, interrupt enable and pending control). alternatively p5.0-p5.7 can be used as outputs for lcd seg. 6 1-bit programmable i/o port. schmitt trigger input or push-pull output mode selected by software; software assignable pull-ups. alternatively p6.0Cp6.2 can be used as cin0Ccin2. 7 4-bit programmable i/o port. input or push-pull output mode selected by software; software assignable pull-ups. alternatively p7.0Cp7.7 can be used as outputs for lcd seg. 8 4-bit programmable i/o port. input or push-pull output mode selected by software; software assignable pull-ups. alternatively p8.0Cp8.7 can be used as outputs for lcd seg. 9 4-bit programmable i/o port. input or push-pull output mode selected by software; software assignable pull-ups. alternatively p9.0Cp9.7 can be used as outputs for lcd seg. 10 4-bit programmable i/o port. input or push-pull output mode selected by software; software assignable pull-ups. alternatively p10.0Cp10.7 can be used as outputs for lcd seg. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 231
port data registers table 9-2 gives you an overview of the register locations of all twelve S3F82NB i/o port data registers. data registers for ports 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 have the general format shown in figure 9-1. table 9-2. port data register summary register name mnemonic decimal hex location r/w port 0 data register p0 0 f0h set 1, bank 1 r/w port 1 data register p1 1 f1h set 1, bank 1 r/w port 2 data register p2 2 f2h set 1, bank 1 r/w port 3 data register p3 3 f3h set 1, bank 1 r/w port 4 data register p4 4 f4h set 1, bank 1 r/w port 5 data register p5 5 f5h set 1, bank 1 r/w port 6 data register p6 6 f6h set 1, bank 1 r/w port 7 data register p7 7 f7h set 1, bank 1 r/w port 8 data register p8 8 f8h set 1, bank 1 r/w port 9 data register p9 9 f9h set 1, bank 1 r/w port 10 data register p10 10 fah set 1, bank 1 r/w msb S3F82NB i/o port data register format (n = 0-10) .7 .6 .5 .4 .3 .2 .1 .0 lsb pn.7 pn.6 pn.5 pn.4 pn.3 pn.2 pn.1 pn.0 figure 9-1. S3F82NB i/o port data register format ps031601-0813 p r e l i m i n a r y S3F82NB product specification 232
port 0 port 0 is an 8-bit i/o port that can be used for general purpose i/o as a/d converter inputs, ad0-ad7. port 0 pins are accessed directly by writing or reading the port 0 data register, p0 at location f0h in set 1, bank 1. p0.0Cp0.7 can serve as inputs (with or without pull-ups), as outputs (push-pull or open-drain). and you can configure the following alternative functions: low-byte pins (p0.0Cp0.3): ad0/t1clk, ad1/t0clk, ad2/t1out/t1pwm/t1cap, ad3/t0out/t0pwm/t0cap high-byte pins (p0.4Cp0.7): ad4-ad7 port 0 control register (p0conh, p0conl) port 0 has two 8-bit control registers: p0conh for p0.4-p0.7 and p0conl for p0.0-p0.3. a reset clears the p0conh and p0conl registers to "00h", configuring all pins to input mode. you use control registers settings to select input or output mode, enable pull-up resistors, select push-pull or open-drain output mode and enable the alternative functions. when programming the port, please remember that any alternative peripheral i/o function you configure using the port 0 control registers must also be enabled in the associated peripheral module. port 0 pull-up resistor enable register (p0pur) using the port 0 pull-up resistor enable register, p0pur (e2h, set1, bank1), you can configure pull-up resistors to individual port 0 pins. alternative function selection register (afsel) using the port 0 alternative function selection register, afsel (e3h, set1, bank1), you can configure alternative mode to p0.2 and p0.3. the ad3 or t0out/t0pwm outputs depend on afsel.1 and the ad2 or t1out/t1pwm outputs depend on afsel.0. port 0 control register, high byte (p0conh) e0h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p0.6/ad6 p0.5/ad5 p0.4/ad4 p0conh bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (ad4-ad7) p0.7/ad7 figure 9-2. port 0 high-byte control register (p0conh) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 233
port 0 control register, low byte (p0conl) e1h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p0.2/ad2 /t1out/t1pwm /t1cap p0.1/ad1 /t0clk p0.0/ad0 /t1clk p0conl bit-pair pin configuration settings: 00 01 10 11 input mode (t0cap, t1cap), schmitt trigger input mode (t0clk, t1clk) output mode, open-drain output mode, push-pull alternative function (ad0, ad1, ad2/t1out/t1pwm, ad3/t0out/t0pwm) p0.3/ad3 /t0out/t0pwm /t0cap note: the p0.2 and p0.3 alternative functions depend on afsel.0 and afsel.1, respectively. figure 9-3. port 0 low-byte control register (p0conl) port 0 pull-up resistor enable register (p0pur) e2h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p0pur bit configuration settings: 0 1 disable pull-up resistor p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 enable pull-up resistor note: a pull-up resistor of port 0 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. figure 9-4. port 0 pull-up resistor enable register (p0pur) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 234
alternative function selection register (afsel) e3h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p0.3 alternative mode selection bit: 0 1 alternative function (ad3) not used for the S3F82NB alternative function (t0out/t0pwm) p0.2 alternative mode selection bit: 0 1 alternative function (ad2) alternative function (t1out/t1pwm) figure 9-5. alternative function selection register (afsel) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 235
port 1 port 1 is an 8-bit i/o port with individually configurable pins. port 1 pins are accessed directly by writing or reading the port 1 data register, p1 at location f1h in set 1, bank 1. p1.0Cp1.7 can serve as inputs (with or without pull- ups), as outputs (push-pull or open-drain). p1.0 is configured as one of the p1.0/int0 and av ref by smart option. and you can configure the following alternative functions: low-byte pins (p1.0-p1.3): av ref high-byte pins (p1.4-p1.7): buz, si, so, sck port 1 control register (p1conh, p1conl) port 1 has two 8-bit control registers: p1conh for p1.4-p1.7 and p1conl for p1.0-p1.3. a reset clears the p1conh and p1conl registers to "00h", configuring all pins to input mode. in input mode, three different selections are available: schmitt trigger input with interrupt generation on falling signal edges. schmitt trigger input with interrupt generation on rising signal edges. schmitt trigger input with interrupt generation on falling/rising signal edges. when programming the port, please remember that any alternative peripheral i/o function you configure using the port 1 control registers must also be enabled in the associated peripheral module. port 1 pull-up resistor enable register (p1pur) using the port 1 pull-up resistor enable register, p1pur (e6h, set1, bank1), you can configure pull-up resistors to individual port 1 pins. port 1 interrupt enable and pending registers (p1inth, p1intl, p1pnd) to process external interrupts at the port 1 pins, the additional control registers are provided: the port 1 interrupt enable register p1inth (high byte, e8h, set 1, bank 1), p1intl (low byte, e9h, set1, bank1) and the port 1 interrupt pending register p1pnd (e7h, set 1, bank 1). the port 1 interrupt pending register p1pnd lets you check for interrupt pending conditions and clear the pending condition when the interrupt service routine has been initiated. the application program detects interrupt requests by polling the p1pnd register at regular intervals. when the interrupt enable bit of any port 1 pin is 1, a rising or falling signal edge at that pin will generate an interrupt request. the corresponding p1pnd bit is then automatically set to 1 and the irq level goes low to signal the cpu that an interrupt request is waiting. when the cpu acknowledges the interrupt request, application software must the clear the pending condition by writing a 0 to the corresponding p1pnd bit. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 236
port 1 control register, high byte (p1conh) e4h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p1conh bit-pair pin configuration settings: 00 01 11 alternative function (buz, so, sck, not used for p1.5) p1.4/int4 /buz p1.5/int5 /si p1.6/int6 /so p1.7/int7 /sck 10 output mode, push-pull schmitt trigger input mode (sck, si) output mode, open-drain figure 9-6. port 1 high-byte control register (p1conh) port 1 control register, low byte (p1conl) e5h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb 00 01 11 not available p1.0/int0 /av ref p1.1/int1 p1.2/int2 p1.3/int3 10 output mode, push-pull schmitt trigger input mode output mode, open-drain p1conl bit-pair pin configuration settings: note: refer to the smart option for configuring as one of the p1.0/int0 and av ref. figure 9-7. port 1 low-byte control register (p1conl) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 237
port 1 pull-up resistor enable register (p1pur) e6h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p1pur bit configuration settings: 0 1 disable pull-up resistor p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 enable pull-up resistor note: a pull-up resistor of port 1 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. figure 9-8. port 1 pull-up resistor enable register (p1pur) port 1 interrupt control register, high byte (p1inth) e8h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb int7 int6 int5 int4 p1inth bit-pair pin configuration settings: 00 01 disable interrupt enable interrupt by falling edge 10 enable interrupt by rising edge 11 enable interrupt by both falling and rising edge figure 9-9. port 1 high-byte interrupt control register (p1inth) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 238
port 1 interrupt control register, low byte (p1intl) e9h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb int3 int2 int1 int0 p1intl bit-pair pin configuration settings: 00 01 disable interrupt enable interrupt by falling edge 10 enable interrupt by rising edge 11 enable interrupt by both falling and rising edge figure 9-10. port 1 low-byte interrupt control register (p1intl) port 1 interrupt pending register (p1pnd) e7h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb pnd7 pnd6 pnd5 pnd4 pnd3 pnd2 pnd1 pnd0 p1pnd bit configuration settings: 0 1 interrupt request is not pending, pending bit clear when write 0 interrupt request is pending figure 9-11. port 1 interrupt pending register (p1pnd) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 239
port 2 port 2 is an 8-bit i/o port with individually configurable pins. port 2 pins are accessed directly by writing or reading the port 2 data register, p2 at location f2h in set 1, bank 1. p2.0Cp2.7 can serve as inputs (with or without pull- ups), as outputs (push-pull or open-drain). and they can serve as segment pins for lcd also. port 2 control register (p2conh, p2conl) port 2 has two 8-bit control registers: p2conh for p2.4Cp2.7 and p2conl for p2.0Cp2.3. a reset clears the p2conh and p2conl registers to 00h, configuring all pins to input mode. you use control registers settings to select input or output mode, enable pull-up resistors, select push-pull or open drain output mode and enable the alternative functions. port 2 pull-up resistor enable register (p2pur) using the port 2 pull-up resistor enable register, p2pur (ech, set1, bank1), you can configure pull-up resistors to individual port 2 pins. port 2 control register, high byte (p2conh) eah, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p2.6/seg62 p2.5/seg61 p2.4/seg60 p2conh bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (seg60-seg63) p2.7/seg63 figure 9-12. port 2 high-byte control register (p2conh) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 240
port 2 control register, low byte (p2conl) ebh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p2.2/seg58 p2.1/seg57 p2.0/seg56 p2conl bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (seg56-seg59) p2.3/seg59 figure 9-13. port 2 low-byte control register (p2conl) port 2 pull-up resistor enable register (p2pur) ech, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p2pur bit configuration settings: 0 1 disable pull-up resistor p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 enable pull-up resistor note: a pull-up resistor of port 2 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. figure 9-14. port 2 pull-up resistor enable register (p2pur) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 241
port 3 port 3 is an 8-bit i/o port with individually configurable pins. port 3 pins are accessed directly by writing or reading the port 3 data register, p3 at location f3h in set 1, bank 1. p3.0Cp3.7 can serve as inputs (with or without pull- ups), as outputs (push-pull or open-drain). and they can serve as segment pins for lcd also. port 3 control register (p3conh, p3conl) port 3 has two 8-bit control registers: p3conh for p3.4Cp3.7 and p3conl for p3.0Cp3.3. a reset clears the p3conh and p3conl registers to 00h, configuring all pins to input mode. you use control registers settings to select input or output mode, enable pull-up resistors, select push-pull or open drain output mode and enable the alternative functions. port 3 pull-up resistor enable register (p3pur) using the port 3 pull-up resistor enable register, p3pur (edh, set1, bank1), you can configure pull-up resistors to individual port 3 pins. port 3 control register, high byte (p3conh) eeh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p3.6/seg70 p3.5/seg69 p3.4/seg68 p3conh bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (seg68-seg71) p3.7/seg71 figure 9-15. port 3 high-byte control register (p3conh) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 242
port 3 control register, low byte (p3conl) efh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p3.2/seg66 p3.1/seg65 p3.0/seg64 p3conl bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (seg64-seg67) p3.3/seg67 figure 9-16. port 3 low-byte control register (p3conl) port 3 pull-up resistor enable register (p3pur) edh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p3pur bit configuration settings: 0 1 disable pull-up resistor p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 enable pull-up resistor note: a pull-up resistor of port 3 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. figure 9-17. port 3 pull-up resistor enable register (p3pur) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 243
port 4 port 4 is an 8-bit i/o port with individually configurable pins. port 4 pins are accessed directly by writing or reading the port 4 data register, p4 at location f4h in set 1, bank 1. p4.0Cp4.7 can serve as inputs (with or without pull- ups), as outputs (push-pull or open-drain). and they can serve as segment pins for lcd also. port 4 control register (p4conh, p4conl) port 4 has two 8-bit control registers: p4conh for p4.4Cp4.7 and p4conl for p4.0Cp4.3. a reset clears the p4conh and p4conl registers to 00h, configuring all pins to input mode. you use control registers settings to select input or output mode, enable pull-up resistors, select push-pull or open drain output mode and enable the alternative functions. port 4 pull-up resistor enable register (p4pur) using the port 4 pull-up resistor enable register, p4pur (d2h, set1, bank1), you can configure pull-up resistors to individual port 4 pins. port 4 control register, high byte (p4conh) d0h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p4.6/seg78 p4.5/seg77 p4.4/seg76 p4conh bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (seg76-seg79) p4.7/seg79 figure 9-18. port 4 high-byte control register (p4conh) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 244
port 4 control register, low byte (p4conl) d1h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p4.2/seg74 p4.1/seg73 p4.0/seg72 p4conl bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (seg72-seg75) p4.3/seg75 figure 9-19. port 4 low-byte control register (p4conl) port 4 pull-up resistor enable register (p4pur) d2h, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p4pur bit configuration settings: 0 1 disable pull-up resistor p4.7 p4.6 p4.5 p4.4 p4.3 p4.2 p4.1 p4.0 enable pull-up resistor note: a pull-up resistor of port 4 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. figure 9-20. port 4 pull-up resistor enable register (p4pur) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 245
port 5 port 5 is an 8-bit i/o port with individually configurable pins. port 5 pins are accessed directly by writing or reading the port 5 data register, p5 at location f5h in set 1, bank 1. p5.0Cp5.7 can serve as inputs (with or without pull- ups), as outputs (push-pull or open-drain). and they can serve as segment pins for lcd also. and you can configure the following alternative functions: high-byte pins (p5.4Cp5.7): int8-int11 port 5 control register (p5conh, p5conl) port 5 has two 8-bit control registers: p5conh for p5.4-p5.7 and p5conl for p5.0-p5.3. a reset clears the p5conh and p5conl registers to "00h", configuring all pins to input mode. in input mode, three different selections are available: schmitt trigger input with interrupt generation on falling signal edges. schmitt trigger input with interrupt generation on rising signal edges. schmitt trigger input with interrupt generation on falling/rising signal edges. port 5 interrupt enable and pending registers (p5int, p5pnd) to process external interrupts at the port 5 pins, the additional control registers are provided: the port 5 interrupt enable register p5int (fbh, set 1, bank 1) and the port 5 interrupt pending register p5pnd (fch, set 1, bank 1). the port 5 interrupt pending register p5pnd lets you check for interrupt pending conditions and clear the pending condition when the interrupt service routine has been initiated. the application program detects interrupt requests by polling the p5pnd register at regular intervals. when the interrupt enable bit of any port 5 pin is 1, a rising or falling signal edge at that pin will generate an interrupt request. the corresponding p5pnd bit is then automatically set to 1 and the irq level goes low to signal the cpu that an interrupt request is waiting. when the cpu acknowledges the interrupt request, application software must the clear the pending condition by writing a 0 to the corresponding p5pnd bit. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 246
port 5 control register, high byte (p5conh) feh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p5.6/int10 /seg86 p5.5/int9 /seg85 p5.4/int8 /seg84 p5conh bit-pair pin configuration settings: 00 01 10 11 schmitt trigger input mode output mode, open-drain output mode, push-pull alternative function (seg84-seg87) p5.7/int11 /seg87 figure 9-21. port 5 high-byte control register (p5conh) port 5 control register, low byte (p5conl) ffh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p5.2/seg82 p5.1/seg81 p5.0/seg80 p5conl bit-pair pin configuration settings: 00 01 10 11 input mode output mode, open-drain output mode, push-pull alternative function (seg80-seg83) p5.3/seg83 figure 9-22. port 5 low-byte control register (p5conl) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 247
port 5 pull-up resistor enable register (p5pur) fdh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p5pur bit configuration settings: 0 1 disable pull-up resistor p5.7 p5.6 p5.5 p5.4 p5.3 p5.2 p5.1 p5.0 enable pull-up resistor note: a pull-up resistor of port 5 is automatically disabled only when the corresponding pin is selected as push-pull output or alternative function. figure 9-23. port 5 pull-up resistor enable register (p5pur) port 5 interrupt control register (p5int) ebh, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb int11 int10 int9 int8 p5int bit-pair pin configuration settings: 00 01 disable interrupt enable interrupt by falling edge 10 enable interrupt by rising edge 11 enable interrupt by both falling and rising edge figure 9-24. port 5 high-byte interrupt control register (p5int) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 248
port 5 interrupt pending register (p5pnd) fch, set 1, bank 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb pnd11 pnd10 pnd9 pnd8 not used for the S3F82NB p5pnd bit configuration settings: 0 1 interrupt request is not pending, pending bit clear when write 0 interrupt request is pending figure 9-25. port 5 interrupt pending register (p5pnd) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 249
port 6 port 6 is a 3-bit i/o port with individually configurable pins. port 6 pins are accessed directly by writing or reading the port 6 data register, p6 at location f6h in set 1, bank 0. p6.0Cp6.2 can serve as inputs (with or without pull- ups), as push-pull outputs. and you can configure the following alternative functions: pins (p6.0-p6.2): cin0, cin1, cin2 port 6 control register (p6con) port 6 has one 8-bit control register: p6con for p6.0Cp6.2. a reset clears the p6con register to 00h, configuring all pins to input mode. you use control registers settings to select input (with or without pull-ups) or push-pull output mode and enable the alternative functions. when programming the port, please remember that any alternative peripheral i/o function you configure using the port 6 control register must also be enabled in the associated peripheral module. port 6 control register (p6con) d2h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p6.2/cin2 p6.1/cin1 p6.0/cin0 p6con bit-pair pin configuration settings: 00 01 10 11 schmitt trigger input mode schmitt trigger input mode, pull-up output mode, push-pull alternative function (cin0-cin2) not used for the S3F82NB figure 9-26. port 6 control register (p6con) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 250
port 7, 8 port 7 and port 8 are 8-bit i/o port with nibble configurable pins, respectively. port 7 and 8 pins are accessed directly by writing or reading the port 7 and 8 data registers, p7 at location f7h and p8 at location f8h in set 1, bank 1. p7.0Cp7.7 and p8.0Cp8.7 can serve as inputs (with or without pull-ups), as push-pull outputs. and they can serve as segment pins for lcd also. port group 1 control register (pg1con) port 6 and 7 have an 8-bit control register: pg1con.0C.3 for p7.0Cp7.7 and pg1con.4C.7 for p8.0Cp8.7. a reset clears the pg1con register to 00h, configuring all pins to input mode. port group 1 control register (pg1con) d1h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p7.0-p7.3 /seg48-seg51 pg1con bit-pair pin configuration settings: 00 01 10 11 input mode input mode, pull-up output mode, push-pull alternative function (seg40-seg55) p8.4-p8.7 /seg44-seg47 p8.0-p8.3 /seg40-seg43 p7.4-p7.7 /seg52-seg55 figure 9-27. port group 1 control register (pg1con) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 251
port 9, 10 port 9 and port 10 are 8-bit i/o port with nibble configurable pins, respectively. port 9 and 10 pins are accessed directly by writing or reading the port 9 and 10 data registers, p9 at location f9h and p10 at location fah in set 1, bank 1. p9.0Cp9.7 and p10.0Cp10.7 can serve as inputs (with or without pull-ups), as push-pull outputs. and they can serve as segment pins for lcd also. port group 0 control register (pg0con) port 9 and 10 have an 8-bit control register: pg0con.0C.3 for p9.0Cp9.7 and pg0con.4C.7 for p10.0Cp10.7. a reset clears the pg0con register to 00h, configuring all pins to input mode. port group 0 control register (pg0con) d0h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb p9.0-p9.3 /seg32-seg35 pg0con bit-pair pin configuration settings: 00 01 10 11 input mode input mode, pull-up output mode, push-pull alternative function (seg24-seg39) p10.4-p10.7 /seg28-seg31 p10.0-p10.3 /seg24-seg27 p9.4-p9.7 /seg36-seg39 figure 9-28. port group 0 control register (pg0con) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 252
10 basic timer overview S3F82NB has an 8-bit basic timer. basic timer (bt) you can use the basic timer (bt) in two different ways: as a watchdog timer to provide an automatic reset mechanism in the event of a system malfunction. to signal the end of the required oscillation stabilization interval after a reset or a stop mode release. the functional components of the basic timer block are: clock frequency divider (f xx divided by 4096, 1024, 128, or 16) with multiplexer 8-bit basic timer counter, btcnt (set 1, bank 0, fdh, read-only) basic timer control register, btcon (set 1, d3h, read/write) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 253
basic timer control register (btcon) the basic timer control register, btcon, is used to select the input clock frequency, to clear the basic timer counter and frequency dividers, and to enable or disable the watchdog timer function. it is located in set 1, address d3h, and is read/write addressable using register addressing mode. a reset clears btcon to "00h". this enables the watchdog function and selects a basic timer clock frequency of f xx /4096. to disable the watchdog function, you must write the signature code "1010b" to the basic timer register control bits btcon.7Cbtcon.4. the 8-bit basic timer counter, btcnt (set 1, bank 0, fdh), can be cleared at any time during the normal operation by writing a "1" to btcon.1. to clear the frequency dividers, write a "1" to btcon.0. basic timer control register (btcon) d3h, set 1, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb divider clear bit: 0 = no effect 1= clear dvider basic timer counter clear bit: 0 = no effect 1= clear btcnt basic timer input clock selection bits: 00 = f xx /4096 01 = f xx /1024 10 = f xx /128 11 = f xx /16 watchdog timer enable bits: 1010b = disable watchdog function other value = enable watchdog function figure 10-1. basic timer control register (btcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 254
basic timer function description watchdog timer function you can program the basic timer overflow signal (btovf) to generate a reset by setting btcon.7Cbtcon.4 to any value other than "1010b". (the "1010b" value disables the watchdog function.) a reset clears btcon to "00h", automatically enabling the watchdog timer function. a reset also selects the cpu clock (as determined by the current clkcon register setting), divided by 4096, as the bt clock. a reset is generated whenever the basic timer counter overflow occurs. during normal operation, the application program must prevent the overflow, and the accompanying reset operation, from occurring, to do this, the btcnt value must be cleared (by writing a 1 to btcon.1) at regular intervals. if a system malfunction occurs due to circuit noise or some other error condition, the bt counter clear operation will not be executed and a basic timer overflow will occur, initiating a reset. in other words, during the normal operation, the basic timer overflow loop (a bit 7 overflow of the 8-bit basic timer counter, btcnt) is always broken by a btcnt clear instruction. if a malfunction does occur, a reset is triggered automatically. oscillation stabilization interval timer function you can also use the basic timer to program a specific oscillation stabilization interval after a reset or when stop mode has been released by an external interrupt. in stop mode, whenever a reset or an external interrupt occurs, the oscillator starts. the btcnt value then starts increasing at the rate of fxx/4096 (for reset), or at the rate of the preset clock source (for an external interrupt). when btcnt.4 overflows, a signal is generated to indicate that the stabilization interval has elapsed and to gate the clock signal off to the cpu so that it can resume the normal operation. in summary, the following events occur when stop mode is released: 1. during the stop mode, a power-on reset or an external interrupt occurs to trigger the stop mode release and oscillation starts. 2. if a power-on reset occurred, the basic timer counter will increase at the rate of fxx/4096. if an interrupt is used to release stop mode, the btcnt value increases at the rate of the preset clock source. 3. clock oscillation stabilization interval begins and continues until bit 4 of the basic timer counter overflows. 4. when a btcnt.4 overflow occurs, the normal cpu operation resumes. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 255
note: during a power-on reset operation, the cpu is idle during the required oscillation stabilization interval (until bit 4 of the basic timer counter overflows). mux f xx /4096 div f xx /1024 f xx /128 f xx /16 f xx bits 3, 2 bit 0 basic timer control register (write '1010 xxxxb' to disable) clear bit 1 reset or stop data bus 8-bit up counter (btcnt, read-only) start the cpu (note) ovf reset r figure 10-2. basic timer block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 256
11 8-bit timer 0 8-bit timer 0 overview the 8-bit timer 0 is an 8-bit general-purpose timer/counter. timer 0 has three operating modes, one of which you select using the appropriate t0con setting: interval timer mode (toggle output at t0out pin) capture input mode with a rising or falling edge trigger at the t0cap pin pwm mode (t0pwm) timer 0 has the following functional components: clock frequency divider (fxx divided by 1024, 256, 64, 8 or 1) with multiplexer external clock input pin (t0clk) 8-bit counter (t0cnt), 8-bit comparator, and 8-bit reference data register (t0data) i/o pins for capture input (t0cap) or pwm or match output (t0pwm, t0out) timer 0 overflow interrupt (irq0 vector dch) and match/capture interrupt (irq0 vector dah) generation timer 0 control register, t0con (set 1, bank 0, e5h, read/write) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 257
timer 0 control register (t0con) you use the timer 0 control register, t0con, to select the timer 0 operating mode (interval timer, capture mode, or pwm mode) select the timer 0 input clock frequency clear the timer 0 counter, t0cnt enable the timer 0 counting operation t0con is located in set 1, bank 0 at address e5h, and is read/write addressable using register addressing mode. a reset clears t0con to '00h'. this sets timer 0 to normal interval timer mode, selects an input clock frequency of fxx/1024, and disable counting operation. you can clear the timer 0 counter at any time during normal operation by writing a "1" to t0con.2. timer interrupt control register (tintcon) you use the timer interrupt control register, tintcon, to enable the timer 0 overflow interrupt or timer 0 match/capture interrupt tintcon is located in set 1, bank 0 at address edh, and is read/write addressable using register addressing mode. the timer 0 overflow interrupt (t0ovf) is interrupt level irq0 and has the vector address dch. when a timer 0 overflow interrupt occurs and is serviced by the cpu, the pending condition is cleared automatically by hardware or must be cleared by software. to enable the timer 0 match/capture interrupt (irq0, vector dah), you must write tintcon.1 to "1". to detect a match/capture interrupt pending condition, the application program polls tintpnd.1. when a "1" is detected, a timer 0 match or capture interrupt is pending. when the interrupt request has been serviced, the pending condition must be cleared by software by writing a "0" to the timer 0 match/capture interrupt pending bit, tintpnd.1. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 258
timer 0 control register (t0con) e5h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 counter operating enable bit: 0 = disable counting operating 1 = enable counting operating not used for the S3F82NB timer 0 counter clear bit: 0 = no effect 1 = clear the timer 0 counter (when write) timer 0 clock selection bits: 000 = fxx/1024 001 = fxx/256 010 = fxx/64 011 = fxx/8 100 = fxx/1 101 = external clock (t0clk) falling edge 110 = external clock (t0clk) rising edge 111 = not available timer 0 operating mode selection bits: 00 = interval mode (t0out) 01 = capture mode (capture on rising edge, counter running, ovf can occur) 10 = capture mode (capture on falling edge, counter running, ovf can occur) 11 = pwm mode (ovf and match interrupt can occur) figure 11-1. timer 0 control register (t0con) timer interrupt control register (tintcon) edh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb ls b timer 0 overflow interupt not used for the S3F82NB tintcon bit configuration settings: 0 disable interrupt 1 enable interrupt timer 0 match/capture interupt timer 1/a overflow interupt timer 1/a match/capture interupt timer b match interupt figure 11-2. timer interrupt control register (tintcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 259
timer interrupt pending register (tintpnd) ech, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 overflow interupt pending bit not used for the S3F82NB 0 = interrupt request is not pending, pending bit clear when write "0" 1 = interrupt request is pending timer 0 match/capture interupt pending bit timer 1/a overflow interupt pending bit timer 1/a match/capture interupt pending bit timer b match interupt pending bit figure 11-3. timer interrupt pending register (tintpnd) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 260
timer 0 function description timer 0 interrupts (irq0, vectors dah and dch) the timer 0 can generate two interrupts: the timer 0 overflow interrupt (t0ovf), and the timer 0 match/capture interrupt (t0int). t0ovf is interrupt level irq0, vector dch. t0int also belongs to interrupt level irq0, but is assigned the separate vector address, dah. a timer 0 overflow interrupt pending condition is automatically cleared by hardware when it has been serviced or should be cleared by software in the interrupt service routine by writing a 0 to the tintpnd.0 interrupt pending bit. however, the timer 0 match/capture interrupt pending condition must be cleared by the applications interrupt service routine by writing a "0" to the tintpnd.1 interrupt pending bit. interval timer mode in interval timer mode, a match signal is generated when the counter value is identical to the value written to the timer 0 reference data register, t0data. the match signal generates a timer 0 match interrupt (t0int, vector dah) and clears the counter. if, for example, you write the value "10h" to t0data, the counter will increment until it reaches 10h. at this point, the timer 0 interrupt request is generated, the counter value is reset, and counting resumes. with each match, the level of the signal at the timer 0 output pin is inverted (see figure 11-4). match signal m u x 8-bit up counter timer 0 buffer register 8-bit comparator timer 0 data register t0con.2 t0con.4-.3 tintpnd.1 capture signal tintcon.1 t0int (irq0) t0out pending interrupt enable/disable match r (clear) clk (match int) t0ovf figure 11-4. simplified timer 0 function diagram: interval timer mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 261
pulse width modulation mode pulse width modulation (pwm) mode lets you program the width (duration) of the pulse that is output at the t0pwm pin. as in interval timer mode, a match signal is generated when the counter value is identical to the value written to the timer 0 data register. in pwm mode, however, the match signal does not clear the counter. instead, it runs continuously, overflowing at "ffh", and then continues incrementing from "00h". although you can use the match signal to generate a timer 0 overflow interrupt, interrupts are not typically used in pwm-type applications. instead, the pulse at the t0pwm pin is held to low level as long as the reference data value is less than or equal to ( ) the counter value and then the pulse is held to high level for as long as the data value is greater than ( > ) the counter value. one pulse width is equal to t clk 256 (see figure 11-5). match signal m u x 8-bit up counter timer 0 buffer register 8-bit comparator timer 0 data register t0con.2 t0con.4-.3 tintpnd.1 capture signal tintcon.1 t0int (irq0) t0pwm output (p0.3) pending interrupt enable/disable match t0ovf(irq0) clk t0ovf high level when data > counter, lower level when data < counter (match int) tintpnd.0 tintcon.0 (overflow int) figure 11-5. simplified timer 0 function diagram: pwm mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 262
capture mode in capture mode, a signal edge that is detected at the t0cap pin opens a gate and loads the current counter value into the timer 0 data register. you can select rising or falling edges to trigger this operation. timer 0 also gives you capture input source: the signal edge at the t0cap pin. you select the capture input by setting the values of the timer 0 capture input selection bits in the port 0 control register, p0conl.7C.6, (set 1, bank 1, e1h). when p0conl.7C.6 is "00" the t0cap input is selected. both kinds of timer 0 interrupts can be used in capture mode: the timer 0 overflow interrupt is generated whenever a counter overflow occurs; the timer 0 match/capture interrupt is generated whenever the counter value is loaded into the timer 0 data register. by reading the captured data value in t0data, and assuming a specific value for the timer 0 clock frequency, you can calculate the pulse width (duration) of the signal that is being input at the t0cap pin (see figure 11-6). m u x t0con.4-.3 tintpnd.1 tintcon.1 t0int (irq0) pending interrupt enable/disable match signal 8-bit up counter timer 0 data register clk t0con.4-.3 t0cap (capture int) t0ovf(irq0) tintpnd.0 tintcon.0 (overflow int) figure 11-6. simplified timer 0 function diagram: capture mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 263
block diagram timer 0 data register timer 0 buffer register 8-bit comparator 8-bit up-counter (read only) clear match t0con.7-.5 f xx /1024 f xx /64 f xx /8 t0clk tintcon.0 t0con.2 m u x t0ovf m u x t0int tintcon.1 t0out t0pwm tintpnd.1 t0con.4-.3 data bus 8 data bus 8 f xx /256 f xx /1 m u x t0cap t0con.4-.3 tintpnd.0 ovf (irq0) match signal t0con.2 t0ovf (irq0) r t0con.1 figure 11-7. timer 0 functional block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 264
12 timer 1 overview the 16-bit timer 1 is used in one 16-bit timer or two 8-bit timers mode. when tacon.0 is set to "1", it is in one 16- bit timer mode. when tacon.0 is set to "0", the timer 1 is used as two 8-bit timers. one 16-bit timer mode (timer 1) two 8-bit timers mode (timer a and b) one 16-bit timers mode (timer 1) overview the 16-bit timer 1 is a 16-bit general-purpose timer. timer 1 has three operating modes, one of which you select using the appropriate tacon setting: interval timer mode (toggle output at t1out pin) capture input mode with a rising or falling edge trigger at the t1cap pin pwm mode (t1pwm) timer 1 has the following functional components: clock frequency divider (fxx divided by 1024, 256, 64, 8, or 1) with multiplexer external clock input pin (t1clk) 16-bit counter (tacnt, tbcnt), 16-bit comparator, and 16-bit reference data register (tadata, tbdata) i/o pins for capture input (t1cap) or pwm or match output (t1pwm, t1out) timer 1 overflow interrupt (irq1 vector e0h) and match/capture interrupt (irq1 vector deh) generation timer 1 control register, tacon (set 1, bank 0, ebh, read/write) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 265
timer 1 control register (tacon) you use the timer 1 control register, tacon, to enable the timer 1 operating (interval timer, capture mode, or pwm mode) select the timer 1 input clock frequency clear the timer 1 counter, tacnt and tbcnt enable the timer 1 counting operating tacon is located in set 1, bank 0, at address ebh, and is read/write addressable using register addressing mode. a reset clears tacon to "00h". this sets timer 1 to disable interval timer mode, selects an input clock frequency of fxx/1024, and disable counting operation. you can clear the timer 1 counter at any time during the normal operation by writing a "1" to tacon.2. timer interrupt control register (tintcon) you use the timer interrupt control register, tintcon, to enable the timer 1/a overflow interrupt or timer 1/a match/capture interrupt tintcon is located in set 1, bank 0 at address edh, and is read/write addressable using register addressing mode. the timer 1 overflow interrupt (t1ovf) is interrupt level irq1 and has the vector address e0h. when a timer 1 overflow interrupt occurs and is serviced by the cpu, the pending condition is cleared automatically by hardware or must be cleared by software. to enable the timer 1 match/capture interrupt (irq1, vector deh), you must write tacon.0 to "1", tacon.1 and tintcon.3 to "1". to detect a match/capture interrupt pending condition, the application program polls tintpnd.3. when a "1" is detected, a timer 1 match or capture interrupt is pending. when the interrupt request has been serviced, the pending condition must be cleared by software by writing a "0" to the timer 1 match/capture interrupt pending bit, tintpnd.3. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 266
timer 1 control register (tacon) ebh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 1 counter operating enable bit: 0 = disable counting operating 1 = enable counting operating timer 1 counter clear bit: 0 = no effect 1 = clear the timer 1 counter (when write) timer 1 clock selection bits: 000 = fxx/1024 001 = fxx/256 010 = fxx/64 011 = fxx/8 100 = fxx/1 101 = external clock (t1clk) falling edge 110 = external clock (t1clk) rising edge 111 = not available timer 1 operating mode selection bits: 00 = interval mode (t1out) 01 = capture mode (capture on rising edge, counter running, ovf can occur) 10 = capture mode (capture on falling edge, counter running, ovf can occur) 11 = pwm mode (ovf and match interrupt can occur) timer 1 operating enable bit: 0 = two 8-bit timer mode (timer a/b) 1 = one 16-bit timer mdoe (timer 1) figure 12-1. timer 1 control register (tacon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 267
timer interrupt control register (tintcon) edh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 overflow interupt not used for the S3F82NB tintcon bit configuration settings: 0 disable interrupt 1 enable interrupt timer 0 match/capture interupt timer 1/a overflow interupt timer 1/a match/capture interupt timer b match interupt figure 12-2. timer interrupt control register (tintcon) timer interrupt pending register (tintpnd) ech, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 overflow interupt pending bit not used for the S3F82NB 0 = interrupt request is not pending, pending bit clear when write "0" 1 = interrupt request is pending timer 0 match/capture interupt pending bit timer 1/a overflow interupt pending bit timer 1/a match/capture interupt pending bit timer b match interupt pending bit figure 12-3. timer interrupt pending register (tintpnd) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 268
timer 1 function description timer 1 interrupts (irq1, vectors deh and e0h) the timer 1 can generate two interrupts: the timer 1 overflow interrupt (t1ovf), and the timer 1 match/ capture interrupt (t1int). t1ovf is belongs to interrupt level irq1, vector e0h. t1int also belongs to interrupt level irq1, but is assigned the separate vector address, deh. a timer 1 overflow interrupt pending condition is automatically cleared by hardware when it has been serviced or should be cleared by software in the interrupt service routine by writing a 0 to the tintpnd.2 interrupt pending bit. however, the timer 1 match/capture interrupt pending condition must be cleared by the applications interrupt service routine by writing a "0" to the tintpnd.3 interrupt pending bit. interval timer mode in interval timer mode, a match signal is generated when the counter value is identical to the value written to the timer 1 reference data register, tbdata/tadata. the match signal generates a timer 1 match interrupt (t1int, vector deh) and clears the counter. if, for example, you write the value "1087h" to tbdata/tadata, the counter will increment until it reaches 1087h. at this point, the timer 1 interrupt request is generated, the counter value is reset, and counting resumes. with each match, the level of the signal at the timer 1 output pin is inverted (see figure 12-4). match signal m u x 16-bit up counter timer 1 buffer register 16-bit comparator timer 1 data register tacon.2 tacon.4-.3 tintpnd.3 capture signal tintcon.3 t1int (irq1) t1out pending interrupt enable/disable match r (clear) clk (match int) t1ovf figure 12-4. simplified timer 1 function diagram: interval timer mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 269
pulse width modulation mode pulse width modulation (pwm) mode lets you program the width (duration) of the pulse that is output at the t1pwm pin. as in interval timer mode, a match signal is generated when the counter value is identical to the value written to the timer 1 data register. in pwm mode, however, the match signal does not clear the counter. instead, it runs continuously, overflowing at "ffffh", and then continues incrementing from "0000h". although you can use the match signal to generate a timer 1 overflow interrupt, interrupts are not typically used in pwm-type applications. instead, the pulse at the t1pwm pin is held to low level as long as the reference data value is less than or equal to ( ) the counter value and then the pulse is held to high level for as long as the data value is greater than ( > ) the counter value. one pulse width is equal to t clk 65536 (see figure 12-5). match signal m u x 16-bit up counter timer 1 buffer register 16-bit comparator timer 1 data register tacon.2 tacon.4-.3 tintpnd.3 capture signal tintcon.3 t1int (irq1) t1pwm pending interrupt enable/disable match t1ovf(irq1) clk t1ovf high level when data > counter, lower level when data < counter (match int) tintpnd.2 tintcon.2 (overflow int) figure 12-5. simplified timer 1 function diagram: pwm mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 270
capture mode in capture mode, a signal edge that is detected at the t1cap pin opens a gate and loads the current counter value into the timer 1 data register. you can select rising or falling edges to trigger this operation. timer 1 also gives you capture input source: the signal edge at the t1cap pin. you select the capture input by setting the values of the timer 1 capture input selection bits in the port 1 control register, p0conl.5C.4, (set 1, bank 1, e1h). when p0conl.5C.4 is "00", the t1cap input is selected. both kinds of timer 1 interrupts can be used in capture mode: the timer 1 overflow interrupt is generated whenever a counter overflow occurs; the timer 1 match/capture interrupt is generated whenever the counter value is loaded into the timer 1 data register. by reading the captured data value in tbdata/tadata, and assuming a specific value for the timer 1 clock frequency, you can calculate the pulse width (duration) of the signal that is being input at the t1cap pin (see figure 12-6). m u x tacon.4-.3 tintpnd.3 tintcon.3 t1int (irq1) pending interrupt enable/disable match signal 16-bit up counter timer 1 data register clk tacon.4-.3 t1cap (capture int) t1ovf(irq1) tintpnd.2 tintcon.2 (overflow int) figure 12-6. simplified timer 1 function diagram: capture mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 271
timer 1 block diagram timer 1 data register (tbdata/tadata) timer 1 buffer register (16-bit) 16-bit comparator 16-bit up-counter (read only) (tbcnt/tacnt) clear match tacon.7-.5 f xx /1024 f xx /64 f xx /8 t1clk tintcon.2 tacon.2 m u x t1ovf m u x t1int tintcon.3 t1out t1pwm tintpnd.3 tacon.4-.3 data bus 16 data bus 16 f xx /256 f xx /1 m u x t1cap tacon.4-.3 tintpnd.2 ovf (irq1) match signal tacon.2 t1ovf (irq1) r pending pending note: when tacon.0 is "1", 16-bit timer 1. tacon.1 figure 12-7. timer 1 functional block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 272
two 8-bit timers mode (timer a and b) overview the 8-bit timer a is an 8-bit general-purpose timer. timer a has three operating modes, one of which you select using the appropriate tacon setting: interval timer mode (toggle output at t1out pin) capture input mode with a rising or falling edge trigger at the t1cap pin pwm mode (t1pwm) timer a has the following functional components: clock frequency divider (fxx divided by 1024, 256, 64, 8, or 1) with multiplexer external clock input pin (t1clk) 8-bit counter (tacnt), 8-bit comparator, and 8-bit reference data register (tadata) i/o pins for capture input (t1cap) or pwm or match output (t1pwm, t1out) timer a overflow interrupt (irq1 vector e0h) and match/capture interrupt (irq1 vector deh) generation timer a control register, tacon (set 1, bank 0, ebh, read/write) the 8-bit timer b is an 8-bit general-purpose timer. timer b includes interval timer mode using appropriate tbcon setting. timer b has the following functional components: clock frequency divider (fxx divided by 1024, 256, 64, 8, or 1) with multiplexer 8-bit counter (tbcnt), 8-bit comparator, and 8-bit reference data register (tbdata) timer b match interrupt (irq2, vector e2h) generation timer b control register, tbcon (set 1, bank 0, eah, read/write) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 273
timer a control register (tacon) you use the timer a control register, tacon, to enable the timer a (interval timer, capture mode, or pwm mode) select the timer a input clock frequency clear the timer a counter, tacnt select the timer a counting operation tacon is located in set 1, bank 0, at address ebh, and is read/write addressable using register addressing mode. a reset clears tacon to "00h". this sets timer a to disable interval timer mode, selects an input clock frequency of fxx/1024, and disables counting operation. you can clear the timer a counter at any time during normal operation by writing a "1" to tacon.2. timer interrupt control register (tintcon) you use the timer interrupt control register, tintcon, to enable the timer 1/a overflow interrupt or timer 1/a match/capture interrupt tintcon is located in set 1, bank 0 at address edh, and is read/write addressable using register addressing mode. the timer a overflow interrupt (t1ovf) is interrupt level irq1 and has the vector address e0h. when a timer a overflow interrupt occurs and is serviced by the cpu, the pending condition is cleared automatically by hardware or must be cleared by software. to enable the timer a match/capture interrupt (irq1, vector deh), you must write tacon.0 to "0", tacon.1 and tintcon.3 to "1". to detect a match/capture interrupt pending condition, the application program polls tintpnd.3. when a "1" is detected, a timer a match or capture interrupt is pending. when the interrupt request has been serviced, the pending condition must be cleared by software by writing a "0" to the timer a match/capture interrupt pending bit, tintpnd.3. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 274
timer a control register (tacon) ebh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer a counter operating enable bit: 0 = disable counting operating 1 = enable counting operating timer a counter clear bit: 0 = no effect 1 = clear the timer a counter (when write) timer a clock selection bits: 000 = fxx/1024 001 = fxx/256 010 = fxx/64 011 = fxx/8 100 = fxx/1 101 = external clock (t1clk) falling edge 110 = external clock (t1clk) rising edge 111 = not available timer a operating mode selection bits: 00 = interval mode (t1out) 01 = capture mode (capture on rising edge, counter running, ovf can occur) 10 = capture mode (capture on falling edge, counter running, ovf can occur) 11 = pwm mode (ovf and match interrupt can occur) timer a operating enable bit: 0 = two 8-bit timer mode (timer a/b) 1 = one 16-bit timer mdoe (timer 1) figure 12-8. timer a control register (tacon) timer interrupt control register (tintcon) edh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 overflow interupt not used for the S3F82NB tintcon bit configuration settings: 0 disable interrupt 1 enable interrupt timer 0 match/capture interupt timer 1/a overflow interupt timer 1/a match/capture interupt timer b match interupt figure 12-9. timer interrupt control register (tintcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 275
timer interrupt pending register (tintpnd) ech, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 overflow interupt pending bit not used for the S3F82NB 0 = interrupt request is not pending, pending bit clear when write "0" 1 = interrupt request is pending timer 0 match/capture interupt pending bit timer 1/a overflow interupt pending bit timer 1/a match/capture interupt pending bit timer b match interupt pending bit figure 12-10. timer interrupt pending register (tintpnd) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 276
timer a function description timer a interrupts (irq1, vectors deh and e0h) the timer a can generate two interrupts: the timer a overflow interrupt (taovf), and the timer a match/capture interrupt (taint). taovf is interrupt level irq1, vector e0h. taint also belongs to interrupt level irq1, but is assigned the separate vector address, deh. a timer a overflow interrupt pending condition is automatically cleared by hardware when it has been serviced or should be cleared by software in the interrupt service routine by writing a 0 to the tintpnd.2 interrupt pending bit. however, the timer a match/capture interrupt pending condition must be cleared by the applications interrupt service routine by writing a "0" to the tintpnd.3 interrupt pending bit. interval timer mode in interval timer mode, a match signal is generated when the counter value is identical to the value written to the timer a reference data register, tadata. the match signal generates a timer a match interrupt (taint, vector deh) and clears the counter. if, for example, you write the value "10h" to tadata, "0" to tacon.0, and 06h to tacon, the counter will increment until it reaches 10h. at this point, the timer a interrupt request is generated, the counter value is reset, and counting resumes. with each match, the level of the signal at the timer a output pin is inverted (see figure 12-11). match signal m u x 8-bit up counter timer a buffer register 8-bit comparator timer a data register tacon.2 tacon.4-.3 tintpnd.3 capture signal tintcon.3 taint (irq1) t1out pending interrupt enable/disable match r (clear) clk (match int) taovf figure 12-11. simplified timer a function diagram: interval timer mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 277
pulse width modulation mode pulse width modulation (pwm) mode lets you program the width (duration) of the pulse that is output at the t1pwm pin. as in interval timer mode, a match signal is generated when the counter value is identical to the value written to the timer a data register. in pwm mode, however, the match signal does not clear the counter. instead, it runs continuously, overflowing at "ffh", and then continues incrementing from "00h". although you can use the match signal to generate a timer a overflow interrupt, interrupts are not typically used in pwm-type applications. instead, the pulse at the t1pwm pin is held to low level as long as the reference data value is less than or equal to ( ) the counter value and then the pulse is held to high level for as long as the data value is greater than ( > ) the counter value. one pulse width is equal to t clk 256 (see figure 12-12). match signal m u x 8-bit up counter timer a buffer register 8-bit comparator timer a data register tacon.2 tacon.4-.3 tintpnd.3 capture signal tintcon.3 taint (irq1) t1pwm pending interrupt enable/disable match taovf(irq1) clk taovf high level when data > counter, lower level when data < counter (match int) tintpnd.2 tintcon.2 (overflow int) figure 12-12. simplified timer a function diagram: pwm mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 278
capture mode in capture mode, a signal edge that is detected at the t1cap pin opens a gate and loads the current counter value into the timer a data register. you can select rising or falling edges to trigger this operation. timer a also gives you capture input source: the signal edge at the t1cap pin. you select the capture input by setting the values of the timer a capture input selection bits in the port 0 control register, p0conl.5C.4, (set 1, bank 1, e1h). when p0conl.5C.4 is "00" the t1cap input is selected. both kinds of timer a interrupts can be used in capture mode: the timer a overflow interrupt is generated whenever a counter overflow occurs; the timer a match/capture interrupt is generated whenever the counter value is loaded into the timer a data register. by reading the captured data value in tadata, and assuming a specific value for the timer a clock frequency, you can calculate the pulse width (duration) of the signal that is being input at the t1cap pin (see figure 12-13). m u x tacon.4-.3 tintpnd.3 tintcon.3 taint (irq1) pending interrupt enable/disable match signal 8-bit up counter timer a data register clk tacon.4-.3 t1cap (capture int) taovf(irq1) tintpnd.2 tintcon.2 (overflow int) figure 12-13. simplified timer a function diagram: capture mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 279
timer a block diagram timer a data register (tadata) timer a buffer register 8-bit comparator 8-bit up-counter (read only) (tacnt) clear match tacon.7-.5 f xx /1024 f xx /64 f xx /8 t1clk tintcon.2 tacon.2 m u x taovf m u x taint tintcon.3 t1out t1pwm tintpnd.3 tacon.4-.3 data bus 8 data bus 8 f xx /256 f xx /1 m u x t1cap tacon.4-.3 tintpnd.2 ovf (irq1) match signal tacon.2 taovf (irq1) r pending pending note: when tacon.0 is "0", two 8-bit timer a/b. tacon.1 figure 12-14. timer a functional block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 280
timer b control register (tbcon) you use the timer b control register, tbcon, to enable the timer b operating (interval timer) select the timer b input clock frequency clear the timer b counter, tbcnt select the timer b counting operation tbcon are located in set 1, bank 0, at address eah, and is read/write addressable using register addressing mode. a reset clears tbcon to "00h". this sets timer b to disable interval timer mode, selects an input clock frequency of fxx/1024, and disables counting operation. you can clear the timer b counter at any time during normal operation by writing a "1" to tbcon.2. timer interrupt control register (tintcon) you use the timer interrupt control register, tintcon, to enable the timer b match interrupt tintcon is located in set 1, bank 0 at address edh, and is read/write addressable using register addressing mode. to enable the timer b match interrupt (irq2, vector e2h), you must write tacon.0 to "0", tbcon.1 and tintcon.4 to "1". to detect a match interrupt pending condition, the application program polls tintpnd.4. when a "1" is detected, a timer b match interrupt is pending. when the interrupt request has been serviced, the pending condition must be cleared by software by writing a "0" to the timer b match interrupt pending bit, tintpnd.4. timer b function description interval timer function the timer b module can generate an interrupt: the timer b match interrupt (tbint). tbint belongs to the interrupt level irq2 and is assigned a separate vector address, e2h. the tbint pending condition should be cleared by software after they are serviced. in interval timer mode, a match signal is generated when the counter value is identical to the values written to the tb reference data registers, tbdata. the match signal generates corresponding match interrupt (tbint, vector e2h) and clears the counter. if, for example, you write the value 10h to tbdata, "0" to tacon.0, and 06h to tbcon, the counter will increment until it reaches 10h. at this point, the tb interrupt request is generated, the counter value is reset, and counting resumes. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 281
timer b control register (tbcon) eah, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer b counter operating enable bit: 0 = disable counting operating 1 = enable counting operating timer b counter clear bit: 0 = no effect 1 = clear the timer b counter (when write) timer b clock selection bits: 000 = fxx/1024 001 = fxx/256 010 = fxx/64 011 = fxx/8 100 = fxx/1 others = not available not used for the S3F82NB not used for the S3F82NB figure 12-15. timer b control register (tbcon) timer interrupt control register (tintcon) edh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 overflow interupt not used for the S3F82NB tintcon bit configuration settings: 0 disable interrupt 1 enable interrupt timer 0 match/capture interupt timer 1/a overflow interupt timer 1/a match/capture interupt timer b match interupt figure 12-16. timer interrupt control register (tintcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 282
timer interrupt pending register (tintpnd) ech, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb timer 0 overflow interupt pending bit not used for the S3F82NB 0 = interrupt request is not pending, pending bit clear when write "0" 1 = interrupt request is pending timer 0 match/capture interupt pending bit timer 1/a overflow interupt pending bit timer 1/a match/capture interupt pending bit timer b match interupt pending bit figure 12-17. timer interrupt pending register (tintpnd) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 283
timer b block diagram tbcon.7-.5 tintpnd.4 tintcon.4 tbint timer b buffer register 8-bit comparator timer b data register (read-only) (tbdata) 8-bit up counter (read-only) (tbcnt) r 8 data bus 8 data bus match mux fxx/1024 fxx/256 fxx/64 fxx/8 fxx/1 clear pending tbcon.1 tbcon.2 (irq2) match signal tbcon.2 note: when tacon.0 is "0", two 8-bit timer a/b. figure 12-18. timer b function block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 284
13 watch timer overview watch timer functions include real-time and watch-time measurement and interval timing for the system clock. to start watch timer operation, set bit 1 of the watch timer control register, wtcon.1 to "1". and if you want to service watch timer overflow interrupt (irq4, vector e6h), then set the wtcon.6 to 1. the watch timer overflow interrupt pending condition (wtcon.0) must be cleared by software in the applications interrupt service routine by means of writing a "0" to the wtcon.0 interrupt pending bit. after the watch timer starts and elapses a time, the watch timer interrupt pending bit (wtcon.0) is automatically set to "1", and interrupt requests commence in 3.91 ms, 0.125, 0.25 and 0.5-second intervals by setting watch timer speed selection bits (wtcon.3C.2). the watch timer can generate a steady 0.5 khz, 1 khz, 2 khz, or 4 khz signal to buz output pin for buzzer. by setting wtcon.3 and wtcon.2 to "11b", the watch timer will function in high-speed mode, generating an interrupt every 3.91 ms. high-speed mode is useful for timing events for program debugging sequences. the watch timer supplies the clock frequency for the lcd controller (f lcd ). therefore, if the watch timer is disabled, the lcd controller does not operate. watch timer has the following functional components: real time and watch-time measurement using a main clock source or sub clock clock source generation for lcd controller (f lcd ) i/o pin for buzzer output frequency generator (buz) timing tests in high-speed mode watch timer overflow interrupt (irq4, vector e6h) generation watch timer control register, wtcon (set 1, bank 0, eeh, read/write) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 285
watch timer control register (wtcon) the watch timer control register, wtcon is used to select the watch timer interrupt time and buzzer signal, to enable or disable the watch timer function. it is located in set 1, bank 0 at address eeh, and is read/write addressable using register addressing mode. a reset clears wtcon to "00h". this disable the watch timer. so, if you want to use the watch timer, you must write appropriate value to wtcon. buzzer signal selection bits: 00 = 0.5 khz 01 = 1 khz 10 = 2 khz 11 = 4 khz watch timer control register (wtcon) eeh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb watch timer int enable/disable bit: 0 = disable watch timer int 1 = enable watch timer int watch timer interrupt pending bit: 0 = interrupt request is not pending (clear pending bit when write"0") 1 = interrupt request is pending watch timer speed selection bits: 00 = set watch timer interrupt to 0.5 s 01 = set watch timer interrupt to 0.25 s 10 = set watch timer interrupt to 0.125 s 11 = set watch timer interrupt to 3.91 ms watch timer clock selection bit: 0 = select main clock divided by 2 7 (fx/128) 1 = select sub clock (fxt) watch timer enable/disable bit: 0 = disable watch timer (clear frequency dividing circuits) 1 = enable watch timer figure 13-1. watch timer control register (wtcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 286
watch timer circuit diagram wt int enable wtcon.1 wtcon.2 wtcon.3 wtcon.4 wtcon.5 wtcon.6 enable/disable selector circuit mux wtcon.0 wtint wtcon.6 3.91msec 0.125sec 0.25sec 0.5sec fw/64 (0.5 khz) fw/32 (1 khz) fw/16 (2 khz) fw/8 (4 khz) fx = main clock (where fx = 4.19 mhz) fxt = sub clock (32.768 khz) fw = watch timer frequency clock selector frequency dividing circuit fw 32.768 khz fxt fx/128 f lcd = 4096 hz wtcon.7 wtcon.0 (pending bit) 8 buz (irq4) figure 13-2. watch timer circuit diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 287
14 lcd controller/driver overview the S3F82NB microcontroller can directly drive an up-to-1280-dot (80 segments x 16 commons) lcd panel. its lcd block has the following components: lcd controller/driver display ram (f00hCfafh) for storing display data in page 15 8 common/segment output pins (com8/seg0Ccom15/seg7) 80 segment output pins (seg8Cseg87) 8 common output pins (com0Ccom7) five lcd operating power supply pins (v lc0 Cv lc4 ) v lc0 pin for controlling the driver and bias voltage lcd contrast control circuit by software (16 steps) the lcd control register, lcon, is used to turn the lcd display on and off, select frame frequency, lcd duty and bias. the lcd mode control register, lmod, is used to control lcd bias voltage by 16 steps. data written to the lcd display ram can be automatically transferred to the segment signal pins without any program control. when a subsystem clock is selected as the lcd clock source, the lcd display is enabled even in the main clock stop or idle modes. lcd controller/driver 8 8-bit data bus 8 8 80 com0-com7 com8-com15 /seg0-seg7 seg8-seg87 5 v lc0 -v lc4 figure 14-1. lcd function diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 288
lcd circuit diagram com0 com15/seg7 com8/seg0 com7 v lc1 v lc0 v lc2 data bus port latch seg/port driver timing controller lcd voltage control f lcd lcon com/port driver lcd display ram (f00h-fafh) seg23 seg8 v lc3 lmod seg32/p9.0 seg24/p10.0 seg40/p8.0 seg48/p7.0 seg56/p2.0 seg64/p3.0 seg72/p4.0 seg87/p5.7 v lc4 contrast controller figure 14-2. lcd circuit diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 289
lcd ram address area ram addresses of 00h - afh page 15 are used as lcd data memory. these locations can be addressed by 1- bit or 8-bit instructions. when the bit value of a display segment is "1", the lcd display is turned on; when the bit value is "0", the display is turned off. display ram data are sent out through the segment pins, seg0Cseg87, using the direct memory access (dma) method that is synchronized with the f lcd signal. ram addresses in this location that are not used for lcd display can be allocated to general-purpose use. com0 com com1 com2 com3 com4 com5 com6 com7 .0 bit .1 .2 .3 .4 .5 .6 .7 seg0 f00h seg1 f02h seg2 f04h seg3 f06h seg4 f08h seg5 f0ah seg85 faah seg86 fach seg87 faeh com15 com13 com12 com11 com10 com9 com8 com14 .0 .1 .2 .3 .4 .5 .6 .7 f01h f03h f05h f07h f09h f0bh fabh fadh fafh figure 14-3. lcd display data ram organization ps031601-0813 p r e l i m i n a r y S3F82NB product specification 290
lcd control register (lcon) a lcon is located in set1, bank0 at address efh, and is read/write addressable using register addressing mode. it has the following control functions. lcd duty and bias selection lcd clock selection lcd display control the lcon register is used to turn the lcd display on/off, to select duty and bias and select lcd clock. a reset clears the lcon registers to "00h", configuring turns off the lcd display, select 1/8 duty and 1/4 bias and select 256hz for lcd clock. the lcd clock signal determines the frequency of com signal scanning of each segment output. this is also referred as the lcd frame frequency. since the lcd clock is generated by watch timer clock (fw). the watch timer should be enabled when the lcd display is turned on. note: the clock and duty for lcd controller/driver is automatically initialized by hardware, whenever lcon register data value is re-write. so, the lcon register dont re-write frequently. lcd control register (lcon) efh, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb not used for the S3F82NB lcd clock selection bits: lcd output control bit: 0 = display off 1 = display on lcd duty selection bit: 0 = 1/8 duty 1 = 1/16 duty lcd bias selection bit: 0 = 1/4 bias 1 = 1/5 bias 000 = fw/2 7 (256 hz) 001 = fw/2 6 (512 hz) 010 = fw/2 5 (1024 hz) 011 = fw/2 4 (2048 hz) others = not available 100 = fw/2 3 (4096 hz) figure 14-4. lcd control register (lcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 291
lcd mode control register (lmod) a lmod is located in set 1, bank 0 at address f0h, and is read/write addressable using register addressing mode. it has the following control functions. lcd contrast control circuit by software (16 steps) the lmod register is used to control the lcd contrast up to 16 step contrast level. a reset clears the lmod registers to "00h", configuring select 1/16 step contrast level and disable lcd contrast control. you cant control lcd contrast by software when the vlcd voltage is supplied by external voltage source. only when you use internal vdd for vlcd voltage, you can control lcd contrast by software. lcd mode control register (lmod) f0h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb not used for the S3F82NB lcd contrast level control bits: 0000 = 1/16 step (the dimmest level) 0001 = 2/16 step 0010 = 3/16 step 1111 = 16/16 step (the brightest level) (v lcd = v dd x (n+17)/32, where n = 0 - 15) lcd contrast enabel/disable selection bit: 0 = disable lcd contrast control 1 = enabel lcd contrast control figure 14-5. lcd mode control register (lmod) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 292
lcd voltage dividing resistor v lc0 lcon.0 v ss 1/5 bias "0" "1" 16 steps of voltage lcon.0 v ss v dd "0" "1" lmod.3=0 contrast controller 16 steps of voltage 1/4 bias v dd lmod.3=0 v lc4 v lc3 v lc2 v lc1 v lcd v lc0 v lc4 v lc3 v lc2 v lc1 v lcd contrast controller application with contrast control v ss "0" "1" v lcd = v dd x (n+17)/32 n = 0, 1, 2, .........., 15 v dd lcon.0 16 steps of voltage lmod.3=1 contrast controller v lc0 v lc4 v lc3 v lc2 v lc1 v lcd figure 14-6. lcd voltage dividing resistor connection ps031601-0813 p r e l i m i n a r y S3F82NB product specification 293
common (com) signals the common signal output pin selection (com pin selection) varies according to the selected duty cycle. in 1/16 duty mode, com0-com15 (seg8Cseg87) pins are selected. in 1/8 duty mode, com0-com7 (seg0Cseg87) pins are selected. segment (seg) signals the 88 lcd segment signal pins are connected to corresponding display ram locations at page 15. bits of the display ram are synchronized with the common signal output pins. when the bit value of a display ram location is "1", a select signal is sent to the corresponding segment pin. when the display bit is "0", a 'no-select' signal to the corresponding segment pin. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 294
com0 seg8 com2 com1 1 frame fr 0 12 30 12 3 15 15 v lc0 v ss com0 com1 com2 com3 com4 com5 com6 com7 s e g 8 s e g 9 s e g 1 0 s e g 1 1 s e g 1 2 com8 com9 com10 com11 com12 com13 com14 com15 v ss v lc1 v lc2 v lc3 v lc4 v lc0 v ss v lc1 v lc2 v lc3 v lc4 v lc0 v ss v lc1 v lc2 v lc3 v lc4 v lc0 v ss v lc1 v lc2 v lc3 v lc4 v lc0 figure 14-7. lcd signal waveforms (1/16 duty, 1/5 bias) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 295
1 frame fr 0 12 30 12 3 15 15 v lc0 v ss seg9 v ss seg8-com0 seg9-com0 v lc1 v lc2 v lc3 v lc4 v lc0 -v lc2 -v lc1 -v lc0 -v lc4 -v lc3 -v lc2 -v lc1 -v lc0 -v lc4 -v lc3 v lc1 v lc2 v lc3 v lc4 v lc0 v lc1 v lc2 v lc3 v lc4 v lc0 0v 0v figure 14-7. lcd signal waveforms (1/16 duty, 1/5 bias) (continued) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 296
1 frame fr v lc0 v ss com0 com1 com2 com3 com4 com5 com6 com7 s e g 0 s e g 1 s e g 2 s e g 3 s e g 4 com1 seg0 com2 com0 seg0-com0 0 12 3 7 46 50 12 3 7 46 5 v lc2 (v lc3 ) v lc4 v ss v lc0 v lc1 v lc2 (v lc3 ) v lc4 v ss v lc0 v lc1 v lc2 (v lc3 ) v lc4 v ss v lc0 v lc1 v lc2 (v lc3 ) v lc4 v ss v lc0 v lc1 v lc2 (v lc3 ) v lc0 v lc1 0v v lc4 -v lc4 -v lc2 (-v lc3 ) -v lc1 -v lc0 figure 14-8. lcd signal waveforms (1/8 duty, 1/4 bias) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 297
1 frame fr v lc0 v ss seg1 seg1-com0 0 12 3 7 46 50 12 3 7 46 5 v lc2 (v lc3 ) v lc4 v ss v lc0 v lc1 v lc0 v lc2 (v lc3 ) 0v v lc4 -v lc4 -v lc2 (-v lc3 ) -v lc0 v lc1 -v lc1 figure 14-8. lcd signal waveforms (1/8 duty, 1/4 bias) (continued) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 298
15 10-bit analog-to-digital converter overview the 10-bit a/d converter (adc) module uses successive approximation logic to convert analog levels entering at one of the eight input channels to equivalent 10-bit digital values. the analog input level must lie between the av ref and av ss values. the a/d converter has the following components: analog comparator with successive approximation logic d/a converter logic (resistor string type) adc control register (adcon) eight multiplexed analog data input pins (ad0Cad7) 10-bit a/d conversion data output register (addatah/l) 8-bit digital input port (alternately, i/o port) av ref and v ss pins function description to initiate an analog-to-digital conversion procedure, at the first you must set adcen signal for adc input enable at port 0, the pin set with alternative function can be used for adc analog input. and you write the channel selection data in the a/d converter control register adcon.4C.6 to select one of the eight analog input pins (ad0C7) and set the conversion start or disable bit, adcon.0. the read-write adcon register is located in set 1, bank 0 at address e2h. the pins which are not used for adc can be used for normal i/o. during a normal conversion, adc logic initially sets the successive approximation register to 200h (the approximate half-way point of an 10-bit register). this register is then updated automatically during each conversion step. the successive approximation block performs 10-bit conversions for one input channel at a time. you can dynamically select different channels by manipulating the channel selection bit value (adcon.6C.4) in the adcon register. to start the a/d conversion, you should set the start bit, adcon.0. when a conversion is completed, adcon.3, the end-of-conversion (eoc) bit is automatically set to 1 and the result is dumped into the addatah/l register where it can be read. the a/d converter then enters an idle state. remember to read the contents of addatah/l before another conversion starts. otherwise, the previous result will be overwritten by the next conversion result. note because the a/d converter has no sample-and-hold circuitry, it is very important that fluctuation in the analog level at the ad0Cad7 input pins during a conversion procedure be kept to an absolute minimum. any change in the input level, perhaps due to noise, will invalidate the result. if the chip enters to stop or idle mode in conversion process, there will be a leakage current path in a/d block. you must use stop or idle mode after adc operation is finished. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 299
conversion timing the a/d conversion process requires 4 steps (4 clock edges) to convert each bit and 10 clocks to set-up a/d conversion. therefore, total of 50 clocks are required to complete an 10-bit conversion: when fxx/8 is selected for conversion clock with an 8 mhz fxx clock frequency, one clock cycle is 1 us. each bit conversion requires 4 clocks, the conversion rate is calculated as follows: 4 clocks/bit  10 bits + set-up time = 50 clocks, 50 clock  1us = 50  s at 1 mhz a/d converter control register (adcon) the a/d converter control register, adcon, is located at address e2h in set1, bank 0. it has three functions: analog input pin selection (adcon.6C.4) end-of-conversion status detection (adcon.3) adc clock selection (adcon.2C.1) a/d operation start or disable (adcon.0) after a reset, the start bit is turned off. you can select only one analog input channel at a time. other analog input pins (ad0Cad7) can be selected dynamically by manipulating the adcon.4C6 bits. and the pins not used for analog input can be used for normal i/o function. start or disable bit: 0 = disable operation 1 = start operation a/d converter control register (adcon) e2h, set1, bank 0, r/w (eoc bit is read-only) .7 .6 .5 .4 .3 .2 .1 .0 msb lsb end-of-conversion bit: 0 = conversion not complete 1 = conversion complete always logic "0" a/d input pin selection bits: 0 0 0 = ad0 0 0 1 = ad1 0 1 0 = ad2 0 1 1 = ad3 1 0 0 = ad4 1 0 1 = ad5 1 1 0 = ad6 1 1 1 = ad7 clock selection bit: 0 0 = fxx/16 0 1 = fxx/8 1 0 = fxx/4 1 1 = fxx/1 figure 15-1. a/d converter control register (adcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 300
a/d converter data register, high byte (addatah) e0h, set 1, bank 0, read only .7 .6 .5 .4 .3 .2 .1 .0 msb lsb a/d converter data register, low byte (addatal) e1h, set1, bank 0, read only .1 .0 msb lsb figure 15-2. a/d converter data register (addatah/l) internal reference voltage levels in the adc function block, the analog input voltage level is compared to the reference voltage. the analog input level must remain within the range av ss to av ref (usually, av ref  v dd, av ss  v ss ). different reference voltage levels are generated internally along the resistor tree during the analog conversion process for each conversion step. the reference voltage level for the first conversion bit is always 1/2 av ref . ps031601-0813 p r e l i m i n a r y S3F82NB product specification 301
block diagram input pins ad0-ad7 (p0.0-p0.7) clock selector conversion result (addatah/l) - + upper 8-bit is loaded to a/d conversion data register to adcon.3 (eoc flag) successive approximation logic & register av ref av ss( v ss) analog comparator 10-bit d/a converter m u x adcon.6-.4 (select one input pin of the assigned pins) p0conh/l (assign pins to adc input) adcon.0 (ad/c enable) adcon.0 (ad/c enable) . . . adcon.2-.1 figure 15-3. a/d converter functional block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 302
av ss (v ss ) S3F82NB ad0-ad7 av ref reference voltage input analog input pin v dd v dd 10  f 103 c 101 c + - (av ref  v dd ) figure 15-4. recommended a/d converter circuit for highest absolute accuracy ps031601-0813 p r e l i m i n a r y S3F82NB product specification 303
16 serial i/o interface overview serial i/o module, sio can interface with various types of external device that require serial data transfer. the components of each sio function block are: 8-bit control register (siocon) clock selector logic 8-bit data buffer (siodata) 8-bit pre-scaler (siops) 3-bit serial clock counter serial data i/o pins (si, so) serial clock input/output pins (sck) the sio module can transmit or receive 8-bit serial data at a frequency determined by its corresponding control register settings. to ensure flexible data transmission rates, you can select an internal or external clock source. programming procedure to program the sio modules, follow these basic steps: 1. configure the i/o pins at port (so, sck, si) by loading the appropriate value to the p6conh register if necessary. 2. load an 8-bit value to the siocon control register to properly configure the serial i/o module. in this operation, siocon.2 must be set to "1" to enable the data shifter. 3. for interrupt generation, set the serial i/o interrupt enable bit (siocon.1) to "1". 4. when you transmit data to the serial buffer, write data to siodata and set siocon.3 to 1, the shift operation starts. 5. when the shift operation (transmit/receive) is completed, the sio pending bit (siocon.0) is set to "1" and an sio interrupt request is generated. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 304
sio control register (siocon) the control register for serial i/o interface module, siocon, is located at f3h in set 1, bank 0. it has the control settings for sio module. clock source selection (internal or external) for shift clock interrupt enable edge selection for shift operation clear 3-bit counter and start shift operation shift operation (transmit) enable mode selection (transmit/receive or receive-only) data direction selection (msb first or lsb first) a reset clears the siocon value to "00h". this configures the corresponding module with an internal clock source at the sck, selects receive-only operating mode, and clears the 3-bit counter. the data shift operation and the interrupt are disabled. the selected data direction is msb-first. serial i/o module control register (siocon) f3h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb sio interrupt enable bit: 0 = disable sio interrupt 1 = enable sio interrupt sio interrupt pending bit: 0 = no interrupt pending 0 = clear pending condition (when write) 1 = interrupt is pending sio shift operation enable bit: 0 = disable shifter and clock counter 1 = enable shifter and clock counter shift clock edge selection bit: 0 = t x at falling edges, rx at rising edges 1 = t x at rising edges, rx at falling edges data direction control bit: 0 = msb-first mode 1 = lsb-first mode sio mode selection bit: 0 = receive only mode 1 = transmit/receive mode sio counter clear and shift start bit: 0 = no action 1 = clear 3-bit counter and start shifting sio shift clock selection bit: 0 = internal clock (p.s clock) 1 = external clock (sck) figure 16-1. serial i/o module control registers (siocon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 305
sio pre-scaler register (siops) the control register for serial i/o interface module, siops, is located at f5h in set 1, bank 0. the value stored in the sio pre-scaler register, siops, lets you determine the sio clock rate (baud rate) as follows: baud rate = input clock (fxx/4)/(pre-scaler value + 1), or sck input clock, where the input clock is fxx/4 sio pre-scaler register (siops) f5h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb baud rate = (fxx/4)/(siops +1) figure 16-2. sio pre-scaler register (siops) block diagram sio int pending 3-bit counter clear siocon.0 fxx/2 siops (f5h, bank 0) sck siocon.7 siocon.1 (interrupt enable) clk si siocon.3 data bus so m u x 1/2 8-bit p.s. irq3 8 8-bit sio shift buffer (siodata, f4h, bank 0) clk siocon.4 (edge select) siocon.5 (mode select) siocon.2 (shift enable) siocon.6 (lsb/msb first mode select) figure 16-3. sio functional block diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 306
serial i/o timing diagram so transmit complete irq4 set siocon.3 do7 do6 do5 do4 do3 do2 do1 do0 di7 di6 di5 di4 di3 di2 di1 di0 si sck figure 16-4. serial i/o timing in transmit/receive mode (tx at falling, siocon.4 = 0) irq4 do7 do6 do5 do4 do3 do2 do1 do0 di7 di6 di5 di4 di3 di2 di1 di0 sck transmit complete si so set siocon.3 figure 16-5. serial i/o timing in transmit/receive mode (tx at rising, siocon.4 = 1) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 307
17 comparator overview p6.0, p6.1 and p6.2 can be used as an analog input port for a comparator. the reference voltage for the 4-channel comparator can be supplied either internally or externally at p6.2. when an internal reference voltage is used, four channels (p6.0-p6.2) are used for analog inputs and the internal reference voltage is varied in 16 levels. if an external reference voltage is input at p6.2, the other p6.0 and p6.1 pins are used for analog input. when a conversion is completed, the result is saved in the comparison result register cmpreg. the initial values of the cmpreg are undefined and the comparator operation is disabled by a reset. the comparator module has the following components: comparator internal reference voltage generator (4-bit resolution) external reference voltage source at p6.2 comparator mode register (cmpcon) comparator result register (cmpreg) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 308
comparator control register (cmpcon) the comparator mode register cmpcon is an 8-bit register that is used to select operation mode of the comparator. it is located in set 1, bank 0 at address f1h, and is read/write addressable using register addressing mode. a reset clears cmpcon to "00h". this disable the comparator, selects conversion time of 8 x 2 5 /fx, the p6.0- p6.2 (cin0-cin2) can be used analog input. cmpcon.6 bit controls conversion timer while cmpcon.7 bit enables or disables comparator operation to reduce power consumption. based on the cmpcon.5 bit setting, an internal or an external reference voltage is input for the comparator, as follows: when cmpcon.5 is set to logic 0: a reference voltage is selected by the cmpcon.0 to cmpcon.3 bit settings. p6.0-p6.2 (cin0-cin2) are used as analog input pins. the internal digital to analog converter generates 16 reference voltages. the comparator can detect 150-mv differences between the reference voltage and the analog input voltages. comparator results are written into bit0-bit2 of the comparison result register (cmpreg) when cmpcon.5 is set to logic 1: a external reference voltage is supplied from p6.2/cin2. p6.0 and p6.1 (cin0-cin1) are used as the analog input pins. the internal digital to analog converter generates 16 reference voltages. the comparator can detect 150-mv differences between the reference voltage and the analog input voltages. bit0 and bit1 in the cmpreg register contain the results. comparator control register f1h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb reference voltage selection bits: selected v ref = v dd x (n+0.5)/16, n = 0 to 15 external/internal reference selection bit: 0 = internal reference, cin0-cin2; analog input 1 = cin2; external reference, cin0-cin1; analog input comparator enable bit: 0 = disable comparator 1 = enable comparator not used, but you must keep "0" conversion time selection bit: 0 = 8 x 2 /fx 1 = 8 x 2 /fx 5 4 figure 17-1. comparator control register (cmpcon) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 309
block diagram p6.0/cin0 p6.2/cin2 p6.1/cin1 mux mux + - comparison result register (cmpreg) v ref (external) cmpcon.7 mux v dd 1/2r r r cmpcon.6 cmpcon.5 0 cmpcon.3 cmpcon.2 cmpcon.1 cmpcon.0 v ref (internal) 3 1/2r note: the comparison result of cin0, cin1 and cin2 are respectively stored in cmpreg.0, cmpreg.1 and cmpreg.2. figure 17-2. comparator circuit diagram ps031601-0813 p r e l i m i n a r y S3F82NB product specification 310
comparator operation the comparator compares analog voltage input at cin0-cin2 with an external or internal reference voltage (v ref ) that is selected by the cmpcon register. the result is written to the comparison result register cmpreg at address f2h, set 1, bank 0. the comparison result at internal reference is calculated as follows: if 1 analog input voltage ? v ref + 150mv if 0 analog input voltage  v ref - 150mv to obtain a comparison result, the data must be read out from the cmpreg register after v ref is updated by changing the cmpcon value after a conversion time has elapsed. comparsion time (cmpclk x8) analog input voltage (cin0-cin2) reference voltage (v ref ) comparator clock (cmpclk, fx/16, fx/32) comparison result (cmpreg) comparsion start comparsion end valid invalid 0 1 1 invalid figure 17-3. conversion characteristics ps031601-0813 p r e l i m i n a r y S3F82NB product specification 311
 programming tip programming the comparator the following code converts the analog voltage input at the cin0-cin2 pins into 3-bit digital code: ld r0,#0fh ld cmpcon,#0cxh ; analog input selection (cin0-cin2) ; x = 0 C f, comparator enable ; internal reference, conversion time (8 x 2 5 /fx) wait0 ld r2,#02h wait1 ld r1,r0 ld r3,#10h wait2 nop djnz r3,wait2 ld r0,cmpreg ; read the result nop nop djnz r2,wait1 cp r0,r1 jr ne,wait0 sb1 ld p2,r0 ; output the result from port 2 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 312
18 embedded flash memory interface overview the S3F82NB has an on-chip flash memory internally instead of masked rom. the flash memory is accessed by 'ldc' instruction and the type of sector erase and a byte programmable flash, a user can program the data in a flash memory area any time you want. the S3F82NB's embedded 64k-bytes memory has two operating features as below: user program mode tool program mode: refer to the chapter 21. S3F82NB flash mcu. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 313
user program mode this mode supports sector erase, byte programming, byte read and one protection mode (hard lock protection). the read protection mode is available only in tool program mode. so in order to make a chip into read protection, you need to select a read protection option when you program an initial your code to a chip by using tool program mode by using a programming tool. the S3F82NB has the pumping circuit internally; therefore, 12.5v into v pp (test) pin is not needed. to program a flash memory in this mode several control registers will be used. there are four kind functions C programming, reading, sector erase and hard lock protection notes 1. the user program mode cannot be used when the cpu operates with the subsystem clock. 2. be sure to execute the di instruction before starting user program mode. the user program mode checks the interrupt request register (irq). if an interrupt request is generated, user program mode is stopped. 3. user program mode is also stopped by an interrupt request that is masked even in the di status. to prevent this, be disable the interrupt by using the each peripheral interrupt enable bit. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 314
flash memory control registers (user program mode) flash memory control register fmcon register is available only in user program mode to select the flash memory operation mode; sector erase, byte programming, and to make the flash memory into a hard lock protection. flash memory control register (fmcon) f9h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb flash operation start bit: 0 = operation stop 1 = operation start (this bit will be cleared automatically just after the corresponding operation completed). sector erase status bit: 0 = success sector erase 1 = fail sector erase flash memory mode selection bits: 0101 = programming mode 1010 = sector erase mode 0110 = hard lock mode others = not available not used for S3F82NB figure 18-1. flash memory control register (fmcon) the bit0 of fmcon register (fmcon.0) is a start bit for erase and hard lock operation mode. therefore, operation of erase and hard lock mode is activated when you set fmcon.0 to "1". also you should wait a time of erase (sector erase) or hard lock to complete it's operation before a byte programming or a byte read of same sector area by using "ldc" instruction. when you read or program a byte data from or into flash memory, this bit is not needed to manipulate. the sector erase status bit is read only. even if imr bits are 0, the interrupt is serviced during the operation of "sector erase", when the each peripheral interrupt enable bit is set 1 and interrupt pending bit is set 1. if an interrupt is requested during the operation of "sector erase", the operation of "sector erase" is discontinued, and the interrupt is served by cpu. therefore, the sector erase status bit should be checked after executing "sector erase". the "sector erase" operation is success if the bit is logic "0", and is failure if the bit is logic "1". note when the id code, "a5h", is written to the fmusr register. a mode of sector erase, user program, and hard lock may be executed unfortunately. so, it should be careful of the above situation. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 315
flash memory user programming enable register the fmusr register is used for a safety operation of the flash memory. this register will protect undesired erase or program operation from malfunctioning of cpu caused by an electrical noise. after reset, the user-programming mode is disabled, because the value of fmusr is "00000000b" by reset operation. if necessary to operate the flash memory, you can use the user programming mode by setting the value of fmusr to "10100101b". the other value of "10100101b", user program mode is disabled. flash memory user programming enable register (fmusr) f8h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb flash memory user programming enable bits: 10100101: enable user programming mode other values: disable user programming mode figure 18-2. flash memory user programming enable register (fmusr) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 316
flash memory sector address registers there are two sector address registers for addressing a sector to be erased. the fmsecl (flash memory sector address register low byte) indicates the low byte of sector address and fmsech (flash memory sector address register high byte) indicates the high byte of sector address. the fmsech is needed for S3F82NB because it has 512 sectors, respectively. one sector consists of 128- bytes. each sector's address starts xx00h or xx80h that is a base address of sector is xx00h or xx80h. so fmsecl register 6-0 don't mean whether the value is '1' or '0'. we recommend that the simplest way is to load sector base address into fmsech and fmsecl register. when programming the flash memory, you should write data after loading sector base address located in the target address to write data into fmsech and fmsecl register. if the next operation is also to write data, you should check whether next address is located in the same sector or not. in case of other sectors, you must load sector address to fmsech and fmsecl register according to the sector. flash memory sector address register (fmsech) f6h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb flash memory setor address (high byte) note: the high-byte flash memory sector address pointer value is the higher eight bits of the 16-bit pointer address. figure 18-3. flash memory sector address register high byte (fmsech) flash memory sector address register (fmsecl) f7h, set 1, bank 0, r/w .7 .6 .5 .4 .3 .2 .1 .0 msb lsb don't care note: the low-byte flash memory sector address pointer value is the lower eight bits of the 16-bit pointer address. flash memory sector address (low byte) figure 18-4. flash memory sector address register low byte (fmsecl) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 317
isp tm (on-board programming) sector isp tm sectors located in program memory area can store on board program software (boot program code for upgrading application code by interfacing with i/o port pin). the isp tm sectors can not be erased or programmed by ldc instruction for the safety of on board program software. the isp sectors are available only when the isp enable/disable bit is set 0, that is, enable isp at the smart option. if you don't like to use isp sector, this area can be used as a normal program memory (can be erased or programmed by ldc instruction) by setting isp disable bit ("1") at the smart option. even if isp sector is selected, isp sector can be erased or programmed in the tool program mode, by serial programming tools. the size of isp sector can be varied by settings of smart option. you can choose appropriate isp sector size according to the size of on board program software. (hex) ffffh 3fh smart option area ffh 8ffh interrupt vector area 64k-bytes internal program memory area available isp sector area 3ch 00h (decimal) 65,535 255 0 byte figure 18-5. program memory address space ps031601-0813 p r e l i m i n a r y S3F82NB product specification 318
table 18-1. isp sector size smart option(003eh) isp size selection bit area of isp sector isp sector size bit 2 bit 1 bit 0 1 x x C 0 0 0 0 100h C 1ffh (256 byte) 256 bytes 0 0 1 100h C 2ffh (512 byte) 512 bytes 0 1 0 100h C 4ffh (1024 byte) 1024 bytes 0 1 1 100h C 8ffh (2048 byte) 2048 bytes note: the area of the isp sector selected by smart option bit (003eh.2 C 003eh.0) can not be erased and programmed by ldc instruction in user program mode. isp reset vector and isp sector size if you use isp sectors by setting the isp enable/disable bit to "0" and the reset vector selection bit to 0 at the smart option, you can choose the reset vector address of cpu as shown in table 18-2 by setting the isp reset vector address selection bits. table 18-2. reset vector address smart option (003eh) isp reset vector address selection bit reset vector address after por usable area for isp sector isp sector size bit 7 bit 6 bit 5 1 x x 0100h C C 0 0 0 0200h 100h C 1ffh 256 bytes 0 0 1 0300h 100h C 2ffh 512 bytes 0 1 0 0500h 100h C 4ffh 1024 bytes 0 1 1 0900h 100h C 8ffh 2048 bytes note: the selection of the isp reset vector address by smart option (003eh.7 C 003eh.5) is not dependent of the selection of isp sector size by smart option (003eh.2 C 003eh.0). ps031601-0813 p r e l i m i n a r y S3F82NB product specification 319
sector erase user can erase a flash memory partially by using sector erase function only in user program mode. the only unit of flash memory to be erased and programmed in user program mode is called sector. the program memory of S3F82NB is divided into 512 sectors for unit of erase and programming, respectively. every sector has all 128-byte sizes of program memory areas. so each sector should be erased first to program a new data (byte) into a sector. minimum 10ms delay time for erase is required after setting sector address and triggering erase start bit (fmcon.0). sector erase is not supported in tool program modes (mds mode tool or programming tool). 0000h ffffh S3F82NB sector 511 (128 byte) ff7fh feffh 3fffh 05ffh 057fh 0500h 3f7fh sector 510 (128 byte) sector 127 (128 byte) sector 11 (128 byte) sector 10 (128 byte) sector 0-9 (128 byte x 10) 04ffh figure 18-6. sector configurations in user program mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 320
the sector erase procedure in user program mode 1. if the procedure of sector erase needs to be stopped by any interrupt, set the appropriately bit of interrupt mask enable register (imr) and the appropriately peripheral interrupt enable bit. otherwise clear all bits of interrupt mask enable register (imr) and all peripheral interrupt enable bits. 2. set flash memory user programming enable register (fmusr) to 10100101b. 3. set flash memory sector address register (fmsech/ fmsecl). 4. check users id code (written by user) 5. set flash memory control register (fmcon) to 10100001b. 6. set flash memory user programming enable register (fmusr) to 00000000b. 7. check the sector erase status bit whether sector erase is success or not.   programming tip sector erase sb0 reerase: ld fmusr,temp0 ; user program mode enable ; temp0 = #0a5h ; temp0 variable is must be setting another routine ld fmsech,#10h ld fmsecl,#00h ; set sector address (1000hC107fh) cp userid_code,#user_value ; check users id code (written by user) ; user_value is any value by user jr ne,not_id_code ; if not equal, jump to not_id_code ld fmcon,temp1 ; start sector erase ; temp1 = #0a1h ; temp1 variable is must be setting another routine nop ; dummy instruction, this instruction must be needed nop ; dummy instruction, this instruction must be needed ld fmusr,#0 ; user program mode disable tm fmcon,#00001000b ; check sector erase status bit jr nz,reerase ; jump to reerase if fail not_id_code: sb0 ld fmusr,#0 ; user program mode disable ld fmcon,#0 ; sector erase mode disable note: in case of flash user mode, the tmep0~temp1s data values are must be setting another routine. temp0~temp(n) variables are should be defined by user. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 321
programming a flash memory is programmed in one byte unit after sector erase. and for programming safety's sake, must set fmsech and fmsecl to flash memory sector value. the write operation of programming starts by 'ldc' instruction. you can write until 128 byte, because this flash sector's limit is 128 byte. so, if you written 128 byte, must reset fmsech and fmsecl. the program procedure in user program mode 1. must erase sector before programming. 2. set flash memory user programming enable register (fmusr) to 10100101b. 3. set flash memory sector register (fmsech, fmsecl) to sector value of write address. 4. load a flash memory upper address into upper register of pair working register. 5. load a flash memory lower address into lower register of pair working register. 6. load a transmission data into a working register. 7. check users id code (written by user) 8. set flash memory control register (fmcon) to 01010001b. 9. load transmission data to flash memory location area on ldc instruction by indirectly addressing mode 10. set flash memory user programming enable register (fmusr) to 00000000b. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 322
  programming tip programming sb0 ld fmusr,temp0 ; user program mode enable ; temp0 = #0a5h ; temp0 variable is must be setting another routine ld fmsech,#17h ld fmsecl,#80h ; set sector address (1780h-17ffh) ld r2,#17h ; set a rom address in the same sector 1780h?17ffh ld r3,#84h ld r4,#78h ; temporary data cp userid_code,#user_value ; check user?s id code (written by user) ; user_value is any value by user jr ne,not_id_code ; if not equal, jump to not_id_code ld fmcon,temp1 ; start program ; temp1 = #51h ; temp1 variable is must be setting another routine ldc @rr2,r4 ; write the data to a address of same sector(1784h) nop ; dummy instruction, this instruction must be needed ld fmusr,#0 ; user program mode disable not_id_code: sb0 ld fmusr,#0 ; user program mode disable ld fmcon,#0 ; programming mode disable note: in case of flash user mode, the tmep0temp1s data values are must be setting another routine. temp0temp(n) variables are should be defined by user. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 323
reading the read operation of programming starts by ldc instruction. the reading procedure in user program mode 1. load a flash memory upper address into upper register of pair working register. 2. load a flash memory lower address into lower register of pair working register. 3. load receive data from flash memory location area on ldc instruction by indirectly addressing mode   programming tip reading ld r2,#3h ; load flash memory upper address ; to upper of pair working register ld r3,#0 ; load flash memory lower address ; to lower pair working register loop: ldc r0,@rr2 ; read data from flash memory location ; (between 300h and 3ffh) inc r3 cp r3,#0h jp nz,loop ps031601-0813 p r e l i m i n a r y S3F82NB product specification 324
hard lock protection user can set hard lock protection by write 0110 in fmcon.7-4. if this function is enabled, the user cannot write or erase the data in a flash memory area. this protection can be released by the chip erase execution (in the tool program mode). in terms of user program mode, the procedure of setting hard lock protection is following that. whereas in tool mode the manufacturer of serial tool writer could support hardware protection. please refer to the manual of serial program writer tool provided by the manufacturer. the hard lock protection procedure in user program mode 1. set flash memory user programming enable register (fmusr) to 10100101b. 2. check users id code (written by user) 3. set flash memory control register (fmcon) to 01100001b. 4. set flash memory user programming enable register (fmusr) to 00000000b.   programming tip hard lock protection sb0 ld fmusr,temp0 ; user program mode enable ; temp0 = #0a5h ; temp0 variable is must be setting another routine cp userid_code,#user_value ; check users id code (written by user) ; user_value is any value by user jr ne,not_id_code ; if not equal, jump to not_id_code ld fmcon,temp1 ; hard lock mode set & start ; temp1 = #61h ; temp1 variable is must be setting another routine nop ; dummy instruction, this instruction must be needed ld fmusr,#0 ; user program mode disable not_id_code: sb0 ld fmusr,#0 ; user program mode disable ld fmcon,#0 ; hard lock protection mode disable note: in case of flash user mode, the tmep0~temp1s data values are must be setting another routine. temp0~temp(n) variables are should be defined by user. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 325
19 electrical data overview in this chapter, S3F82NB electrical characteristics are presented in tables and graphs. the information is arranged in the following order: absolute maximum ratings input/output capacitance d.c. electrical characteristics a.c. electrical characteristics oscillation characteristics oscillation stabilization time data retention supply voltage in stop mode lvr timing characteristics a/d converter electrical characteristics serial i/o timing characteristics comparator electrical characteristics lcd contrast controller electrical characteristics internal flash rom electrical characteristics operating voltage range ps031601-0813 p r e l i m i n a r y S3F82NB product specification 326
table 19-1. absolute maximum ratings (t a = 25  c) parameter symbol conditions rating unit supply voltage v dd C C 0.3 to + 6.5 input voltage v i ports 0-10 C 0.3 to v dd + 0.3 output voltage v o C C 0.3 to v dd + 0.3 v one i/o pin active C 15 output current high i oh all i/o pins active C 60 one i/o pin active + 30 (peak value) output current low i ol total pin current for ports + 100 (peak value) ma operating temperature t a C C 40 to + 85 storage temperature t stg C C 65 to + 150  c table 19-2. d.c. electrical characteristics (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol conditions min typ max unit operating voltage v dd f x = 0.4C4.2 mhz, f xt = 32.768 khz 1.8 C 5.5 v f x = 0.4C12.0 mhz 2.2 C 5.5 input high voltage v ih1 all input pins except v ih2, 3 0.7v dd C v dd v ih2 p0.0-p0.1, p1, p5.4-p5.7, p6, nreset 0.8v dd v dd v ih3 x in , x out , xt in , xt out v dd C0.1 v dd input low voltage v il1 all input pins except v il2, 3 C C 0.3v dd v il2 p0.0-p0.1, p1, p5.4-p5.7, p6, nreset 0.2v dd v il3 x in , x out , xt in , xt out 0.1 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 327
table 19-2. d.c. electrical characteristics (continued) (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol conditions min typ max unit output high voltage v oh v dd = 4.5v to 5.5v i oh = C1ma all output ports v dd C1.0 C C v dd = 4.5v to 5.5v i ol = 15ma all output ports C C 2.0 output low voltage v ol v dd = 1.8v to 5.5v i ol = 1.6ma 0.4 v i lih1 v in = v dd all input pins except i lih2 C C 3 input high leakage current i lih2 v in = v dd x in , x out , xt in , xt out 20 i lil1 v in = 0 v all input pins except for nreset, i lil2 C C C3 input low leakage current i lil2 v in = 0 v x in , x out , xt in , xt out C20 output high leakage current i loh v out = v dd all output pins C C 3 output low leakage current i lol v out = 0 v all output pins C C C3  a lcd voltage dividing resistor r lcd t a = 25  c 40 60 80 r osc1 v dd = 5 v, t a = 25  c x in = v dd , x out = 0 v 420 850 1700 oscillator feed back resistors r osc2 v dd = 5 v, t a = 25  c xt in = v dd , xt out = 0 v 2200 4500 9000 v in = 0 v; v dd = 5 v t a = 25  c, ports 0C10 25 50 100 r l1 v in = 0 v; v dd = 3 v t a = 25  c, ports 0C10 50 100 150 v in = 0 v; v dd = 5 v t a = 25  c, nreset 150 250 400 k  pull-up resistor r l2 v in = 0 v; v dd = 3 v t a = 25  c, nreset 300 500 700 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 328
table 19-2. d.c. electrical characteristics (continued) (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol conditions min typ max unit v lc1 0.8v dd C0.2 0.8v dd 0.8v dd +0.2 v lc2 0.6v dd C0.2 0.6v dd 0.6v dd +0.2 v lc3 0.4v dd C0.2 0.4v dd 0.4v dd +0.2 middle output voltage (note) v lc4 v dd = 2.4v to 5.5v, 1/5 bias lcd clock = 0hz, v lc0 = v dd 0.2v dd C0.2 0.2v dd 0.2v dd +0.2 v |v lcd C comi| voltage drop (i = 0 C 15) v dc C15  a per common pin C C 120 |v lcd C segx| voltage drop (x = 0 C 87) v ds C15  a per segment pin CC 120 mv note: it is middle output voltage when the v dd and v lc0 pin are connected. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 329
table 19-2. d.c. electrical characteristics (concluded) (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol conditions min typ max unit 12.0 mhz C 2.2 4.0 run mode: v dd = 5.0v crystal oscillator c1 = c2 = 22pf 4.2 mhz 1.2 2.0 i dd1 (2) v dd = 3.0v 4.2 mhz 0.8 1.5 12.0 mhz C 1.3 2.3 idle mode: v dd = 5.0v crystal oscillator c1 = c2 = 22pf 4.2 mhz 0.8 1.5 i dd2 (2) v dd = 3.0v 4.2 mhz 0.4 0.8 ma i dd3 (3) sub operating mode: v dd = 3.0v 32khz crystal oscillator C 65.0 100.0 i dd4 (3) sub idle mode: v dd = 3.0v 32khz crystal oscillator C 6.0 15.0 supply current (1) i dd5 (4) stop mode: v dd = 5.0v C 0.3 6.0  a notes: 1. supply current does not include current drawn through internal pull-up resistors, lcd voltage dividing resistors, the lvr block, and external output current loads. 2. i dd1 and i dd2 include a power consumption of sub clock oscillation. 3. i dd3 and i dd4 are the current when the main clock oscillation stops and the sub clock is used. 4. i dd5 is the current when the main and sub clock oscillation stops. 5. every value in this table is measured when bits 4-3 of the system clock control register (clkcon.4C.3) is set to 11b. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 330
table 19-3. a.c. electrical characteristics (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol conditions min typ max unit interrupt input high, low width (p1.0-p1.7, p5.4-p5.7) t inth , t intl all interrupt, v dd = 5 v 500 C C ns nreset input low width t rsl input, v dd = 5 v 10 C C  s note: if width of interrupt or reset pulse is greater than min. value, pulse is always recognized as valid pulse. t inth t intl 0.8 v dd 0.2 v dd external interrupt figure 19-1. input timing for external interrupts nreset t rsl 0.2 v dd figure 19-2. input timing for nreset ps031601-0813 p r e l i m i n a r y S3F82NB product specification 331
table 19-4. input/output capacitance (t a = C 40  c to + 85  c, v dd = 0 v ) parameter symbol conditions min typ max unit input capacitance c in f = 1 mhz; unmeasured pins are returned to v ss C C 10 pf output capacitance c out i/o capacitance c io table 19-5. data retention supply voltage in stop mode (t a = C 40  c to + 85  c) parameter symbol conditions min typ max unit data retention supply voltage v dddr 1.8 C 5.5 v data retention supply current i dddr stop mode, t a = 25  c v dddr = 1.8v disable lvr block C C 1  a ps031601-0813 p r e l i m i n a r y S3F82NB product specification 332
execution of stop instrction nreset occurs ~ ~ v dddr ~ ~ stop mode oscillation stabilization time normal operating mode data retention mode t wait nreset v dd note: t wait is the same as 4096 x 16 x 1/fxx. 0.2 v dd 0.8 v dd figure 19-3. stop mode release timing initiated by nreset ~ ~ t wait normal operation mode 0.2v dd v dddr data retention mode ~ ~ stop mode execution of stop instruction v dd interrupt note: t wait is the same as 16 x 1/f bt . (f bt is basic timer clock selected) idle mode oscillation stabillization time figure 19-4. stop mode release timing initiated by interrupts ps031601-0813 p r e l i m i n a r y S3F82NB product specification 333
table 19-6. a/d converter electrical characteristics (t a = C 40  c to + 85  c, v dd = 2.7 v to 5.5 v) parameter symbol conditions min typ max unit resolution C C C 10 C bit total accuracy C C C C  3 lsb integral linearity error ile C C  2 differential linearity error dle C  1 offset error of top eot  1  3 offset error of bottom eob v dd = 5.120 v v ss = 0 v cpu clock = 12.0 mhz  1  3 conversion time (1) t con C 25 C C  s analog input voltage v ian C v ss C av ref v analog input impedance r an C 2 1000 C m  analog reference voltage av ref C 1.8 C v dd v analog input current i adin v dd = 5.0 v C C 10  a i adc v dd = 5.0 v C 0.5 1.5 ma analog block current (2) v dd = 5.0 v when power down mode 100 500 na notes: 1. 'conversion time' is the time required from the moment a conversion operation starts until it ends. 2. i adc is an operating current during a/d converter. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 334
table 19-7. synchronous sio electrical characteristics (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol conditions min typ max unit sck cycle time t kcy external sck source 1,000 C C ns internal sck source 1,000 sck high, low width t kh , t kl external sck source 500 internal sck source t kcy /2-50 si setup time to sck high t sik external sck source 250 internal sck source 250 si hold time to sck high t ksi external sck source 400 internal sck source 400 output delay for sck to so t kso external sck source C 300 internal sck source 250 output data input data sck t kh t kcy t kl 0.8 v dd 0.2 v dd t kso t sik t ksi 0.8 v dd 0.2 v dd si so figure 19-5. serial data transfer timing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 335
table 19-8. low voltage reset electrical characteristics (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol test condition min typ max unit voltage of lvr v lvr C 1.9 2.0 2.1 v v dd voltage rising time t r C 10 C C  s v dd voltage off time t off C 0.5 C C s hysteresis lvr ^ v C C 10 100 mv current consumption i lvr v dd = 3.0 v C 30 60  a note: the current of lvr circuit is consumed when lvr is enabled by smart option. v dd t off 0.1v dd 0.9v dd t r figure 19-6. lvr (low voltage reset) timing ps031601-0813 p r e l i m i n a r y S3F82NB product specification 336
table 19-9. comparator converter electrical characteristics (t a = C 40  c to + 85  c, v dd = 4.0 v to 5.5 v) parameter symbol condition min typ max unit input voltage range C C 0 C v dd v reference voltage range v ref C 0 C v dd v 8 x 2 5 /fx, @0.4 ~ 12.0 mhz input voltage accuracy v cin 8 x 2 4 /fx, @0.4 ~ 6.0 mhz C C  150 mv input leakage current i cin , i ref C C 3 C 3  a table 19-10. lcd contrast controller electrical characteristics (t a = C 40  c to + 85  c, v dd = 4.5 v to 5.5 v) parameter symbol condition min typ max unit resolution C C C C 4 bits linearity r lin v dd = 5.0 v C C  150 mv max output voltage v lpp v lc0 = v dd = 5.0 v lmod = #f8h 4.9 C v lc0 v ps031601-0813 p r e l i m i n a r y S3F82NB product specification 337
table 19-11. main oscillator characteristics (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) oscillator clock configuration parameter test condition min typ max units main oscillation frequency 2.2 v C 5.5 v 0.4 C 12.0 mhz crystal x in c1 x out 1.8 v C 5.5 v 0.4 C 4.2 main oscillation frequency 2.2 v C 5.5 v 0.4 C 12.0 ceramic oscillator x in c1 x out 1.8 v C 5.5 v 0.4 C 4.2 x in input frequency 2.2 v C 5.5 v 0.4 C 12.0 external clock x in x out 1.8 v C 5.5 v 0.4 C 4.2 frequency 3.0 v 0.4 C 1 rc oscillator x in x out r 5.0 v 0.4 C 2 mhz table 19-12. sub oscillation characteristics (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) oscillator clock configuration parameter test condition min typ max units crystal xt in c1 xt out c2 sub oscillation frequency 1.8 v C 5.5 v C 32.768 C khz external clock xt in xt out xt in input frequency 1.8 v C 5.5 v 32 C 100 ps031601-0813 p r e l i m i n a r y S3F82NB product specification 338
table 19-13. main oscillation stabilization time (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) oscillator test condition min typ max unit crystal C C 40 ms ceramic fx > 1 mhz oscillation stabilization occurs when v dd is equal to the minimum oscillator voltage range. C C 10 ms external clock x in input high and low width (t xh , t xl ) 62.5 C 1250 ns x in 1/fx 0.1v t xl t xh v dd - 0.1v 0.1v figure 19-7. clock timing measurement at x in table 19-14. sub oscillation stabilization time (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) oscillator test condition min typ max unit crystal C C C 10 s external clock xt in input high and low width (t xth , t xtl ) 5 C 15  s xt in 1/fxt 0.1v t xtl t xth v dd - 0.1v 0.1v figure 19-8. clock timing measurement at xt in ps031601-0813 p r e l i m i n a r y S3F82NB product specification 339
supply voltage (v) cpu clock = 1/4n x oscillator frequency (n = 1, 2, 8, 16) instruction clock 400 khz 1.8v 3 12.0 mhz main oscillation frequency 3.0mhz 1.05 mhz 100 khz 4.2 mhz 5.5v 2.0 mhz 0.5 mhz 54 2.2v figure 19-9. operating voltage range table 19-15. internal flash rom electrical characteristics (t a = C 40  c to + 85  c, v dd = 1.8 v to 5.5 v) parameter symbol conditions min typ max unit programming time (1) ftp C 20 25 30  s chip erasing time (2) ftp1 32 50 70 ms sector erasing time (3) ftp2 4 8 12 ms read frequency f r C C C 12 mhz number of writing/erasing fn we C C C 10,000 (4) times notes: 1. the programming time is the time during which one byte (8-bit) is programmed. 2. the chip erasing time is the time during which all 64k byte block is erased. 3. the sector erasing time is the time during which all 128 byte block is erased. 4. the chip erasing is available in tool program mode only. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 340
notes ps031601-0813 p r e l i m i n a r y S3F82NB product specification 341
20 mechanical data overview the S3F82NB microcontroller is currently available in 128-pin-qfp package. 128-qfp-1420 #128 20.00  0.20 22.00  0.30 14.00  0.20 16.00   0.30 0.15 + 0.10 - 0.05 0-8 0.10 max #1 note : dimensions are in millimeters. (0.75) 0.50  0.20 0.05 min 2.10  0.10 2.40 max 0.50   0.20 0.50 0.20 + 0.10 - 0.05 (0.75) 0.10 max 0.10 max figure 20-1. package dimensions (128-qfp-1420) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 342
21 S3F82NB flash mcu overview the S3F82NB single-chip cmos microcontroller is the flash mcu. it has an on-chip flash mcu rom. the flash rom is accessed by serial data format. note this chapter is about the tool program mode of flash mcu. if you want to know the user program mode, refer to the chapter 18. embedded flash memory interface. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 343
S3F82NB 128-qfp-1420 com9/seg1 com8/seg0 com7 com6 com5 com4 com3 com2 com1 com0 v lc4 v lc3 v lc2 v lc1 v lc0 p1.7/sck/int7 p1.6/so/int6 sdat /p1.5/si/int5 sclk /p1.4/buz/int4 vdd /v dd vss/v ss x out x in vpp/test xt in xt out nreset /nreset p1.3/int3 p1.2/int2 p1.1/int1 p1.0/av ref /int0 p0.7/ad7 p0.6/ad6 p0.5/ad5 p0.4/ad4 p0.3/t0out/t0pwm/t0cap/ad3 p0.2/t1out/t1pwm/t1cap/ad2 p0.1/t0clk/ad1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 p10.4/seg28 p10.5/seg29 p10.6/seg30 p10.7/seg31 p9.0/seg32 p9.1/seg33 p9.2/seg34 p9.3/seg35 p9.4/seg36 p9.5/seg37 p9.6/seg38 p9.7/seg39 p8.0/seg40 p8.1/seg41 p8.2/seg42 p8.3/seg43 p8.4/seg44 p8.5/seg45 p8.6/seg46 p8.7/seg47 p7.0/seg48 p7.1/seg49 p7.2/seg50 p7.3/seg51 p7.4/seg52 p7.5/seg53 p7.6/seg54 p7.7/seg55 p2.0/seg56 p2.1/seg57 p2.2/seg58 p2.3/seg59 p2.4/seg60 p2.5/seg61 p2.6/seg62 p2.7/seg63 p3.0/seg64 p3.1/seg65 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 p0.0/t1clk/ad0 p6.2/cin2 p6.1/cin1 p6.0/cin0 p5.7/int11/seg87 p5.6/int10/seg86 p5.5/int9/seg85 p5.4/int8/seg84 p5.3/seg83 p5.2/seg82 p5.1/seg81 p5.0/seg80 p4.7/seg79 p4.6/seg78 p4.5/seg77 p4.4/seg76 p4.3/seg75 p4.2/seg74 p4.1/seg73 p4.0/seg72 p3.7/seg71 p3.6/seg70 p3.5/seg69 p3.4/seg68 p3.3/seg67 p3.2/seg66 com10/seg2 com11/seg3 com12/seg4 com13/seg5 com14/seg6 com15/seg7 seg8 seg9 seg10 seg11 seg12 seg13 seg14 seg15 seg16 seg17 seg18 seg19 seg20 seg21 seg22 seg23 p10.0/seg24 p10.1/seg25 p10.2/seg26 p10.3/seg27 figure 21-1. S3F82NB pin assignments (100-qfp-1420) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 344
table 21-1. descriptions of pins used to read/write the flash rom main chip during programming pin name pin name pin no. i/o function p1.5 sdat 18 i/o serial data pin. output port when reading and input port when writing. can be assigned as a input/push-pull output port. p1.4 sclk 19 i/o serial clock pin. input only pin. test v pp 24 i tool mode selection when test/ v pp pin sets logic value 1. if user uses the flash writer tool mode (ex.spw2+ etc..), user should be connected test/ v pp pin to v dd . (S3F82NB supplies high voltage 12.5v by internal high voltage generation circuit.) nreset nreset 27 i chip initialization v dd , v ss v dd , v ss 20, 21  power supply pin for logic circuit. v dd should be tied to 5.0v during programming. test pin voltage the test pin on socket board for mtp writer must be connected to v dd (5.0v) with rc delay as the figure 21-2 (only when spw 2+ and gw-pro2 are used to). the test pin on socket board must not be connected vpp (12.5v) which is generated from mtp writer. so the specific socket board for S3F82NB must be used, when writing or erasing using mtp writer. } ww v dd r (330 3 ) c (0.1uf) figure 21-2. rc delay circuit ps031601-0813 p r e l i m i n a r y S3F82NB product specification 345
on board writing the S3F82NB needs only 6 signal lines including v dd and v ss pins for writing internal flash memory with serial protocol. therefore the on-board writing is possible if the writing signal lines are considered when the pcb of application board is designed. circuit design guide at the flash writing, the writing tool needs 6 signal lines that are v ss , v dd , nreset, test, sdat and sclk. when you design the pcb circuits, you should consider the usage of these signal lines for the on-board writing. in case of test pin, normally test pin is connected to v ss but in writing mode the programming these two cases, a resistor should be inserted between the test pin and v ss . the nreset, sdat and sclk should be treated under the same consideration. please be careful to design the related circuit of these signal pins because rising/falling timing of v pp , sclk and sdat is very important for proper programming. g v dd v ss v dd gnd sclk sdat nreset v pp c nreset and c v pp are used to improve the noise effect. r sclk to application circuit sclk(i/o) r sdat sdat(i/o) r nreset nreset r v pp v pp (test) c v pp c nreset , spw-uni , as-pro, us-pro gw-uni to application circuit to application circuit note: if writer tool is the spw 2+ and gw-pro2, reference to the page 21-3. figure 21-3. pcb design guide for on board programming ps031601-0813 p r e l i m i n a r y S3F82NB product specification 346
reference table for connection table 21-2. reference table for connection pin name i/o mode in applications resistor (need) required value vpp (test) input yes r vpp is 10 kohm ~ 50 kohm. c vpp is 0.01uf ~ 0.02uf. nreset input yes r nreset is 2 kohm ~ 5 kohm. c nreset is 0.01uf ~ 0.02uf. input yes r sdat is 2 kohm ~ 5 kohm. sdat(i/o) output no (note)  input yes r sclk is 2 kohm ~ 5 kohm. sclk(i/o) output no (note)  notes: 1. in on-board writing mode, very high-speed signal will be provided to pin sclk and sdat. and it will cause some damages to the application circuits connected to sclk or sdat port if the application circuit is designed as high speed response such as relay control circuit. if possible, the i/o configuration of sdat, sclk pins had better be set to input mode. 2. the value of r, c in this table is recommended value. it varies with circuit of system. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 347
22 development tools overview samsung provides a powerful and easy-to-use development support system on a turnkey basis. the development support system is composed of a host system, debugging tools, and supporting software. for a host system, any standard computer that employs win95/98/2000/xp as its operating system can be used. a sophisticated debugging tool is provided both in hardware and software: the powerful in-circuit emulator, openice-i500 and sk- 1200, for the s3c7-, s3c9-, and s3c8- microcontroller families. samsung also offers supporting software that includes, debugger, an assembler, and a program for setting options. target boards target boards are available for all the s3c8/s3f8-series microcontrollers. all the required target system cables and adapters are included on the device-specific target board. tb82nb is a specific target board for the development of application systems using S3F82NB. programming socket adapter when you program S3F82NBs flash memory by using an emulator or otp/mtp writer, you need a specific programming socket adapter for S3F82NB. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 348
bus emulator [sk-1200 (rs-232, usb) or openice i-500 (rs-232) ] rs-232c/usb pod probe adapter otp/mtp writer block ram break/display block trace/timer block sam8 base block power supply block ibm-pc at or compatible tb82nb target board evachip target application system figure 22-1. emulator product configuration ps031601-0813 p r e l i m i n a r y S3F82NB product specification 349
tb82nb target board the tb82nb target board can be used for development of the S3F82NB microcontroller. the tb82nb target board is operated as target cpu with emulator (sk-1200, openice-i500)). tb82nb reset idle + stop + 7411 u2 v dd gnd y1 (sub-clock) j101 64-pin connector 2 1 63 64 64-pin connector 66 65 127 128 j102 208 qfp s3e82n0 eva chip 50 60 100 110 150 160 200 1 j1 100-pin connector 25 1 j2 to user_v cc off on 100-pin connector j2 in-circuit emulator (sk-1200, openice-i500) v dd v cc a vref cn4 v lc1 v lc0 v lc2 v lc3 cn2 v lc4 v dd smart option selection on sw1 1 23 45 6 78 910 b0 b1 b2 b3 b5 b6 b7 b4 b8 b9 "0" "1" 4 jp2 tp1 external internal jp1 (smart option source) cn1 nreset vss vdd vpp sdat sclk cn6 (tb mode selection) main mode eva mode figure 22-2. tb82nb target board configuration note: the symbol marks start point of jumper signals. ps031601-0813 p r e l i m i n a r y S3F82NB product specification 350
table 22-1. components of tb82nb symbols usage description j2 100-pin connector connection between emulator and tb82nb target board. j101, j102 64-pin connector connection between target board and user application system reset push button generation low active reset signal to S3F82NB eva-chip vdd, gnd power connector external power connector for tb82nb stop, idle led stop/idle display indicate the status of stop or idle of S3F82NB eva-chip on tb82nb target board cn1 flash serial programming signal points for programming flash rom by external programmer. dont use this one in user mode. cn6 tb mode selection selection of eva/main-chip mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 351
table 22-2. setting of the jumper in tb82nb jp# description 1-2 connection 2-3 connection default setting vdd user power join 2-3 cn4 av ref power source you should activate avref on the tb82nb by setting the related tp1. tp1 p1.0/int0 or av ref selection tp1 should be used p1.0/int0 normally. if user wants to use the av ref , user should be connected to vss. cn6 target board mode selection h: main-mode l: eva-mode join 2-3 jp2 clock source selection when using the internal clock source which is generated from emulator, join connector 2-3 and 4-5 pin. if user wants to use the external clock source like a crystal, user should change the jumper setting from 1-2 to 5-6 and connect j1 to an external clock source. j1 external clock source connecting points for external clock source emulator 2-3 4-5 jp1 smart option source selection the smart option is selected by external smart option switch (sw1) the smart option is selected by internal smart option area (003ehC0003fh of rom). but this selection is not available. join 1-2 sw1 smart option selection the smart option can be selected by this switch when the smart option source is selected by external. the b2Cb0 are comparable to the 003eh.2C.0. the b7Cb5 are comparable to the 003eh.7C.5. the b8 is comparable to the 003fh.0. the b4Cb3 and b9 are not connected. the tp1 is comparable to the 003fh.7. refer to the page 2-3. cn1 header for flash serial programming signals to program an internal flash, connect the signals with flash writer tool. to user_vcc target system is supplied v dd target board is not supplied v dd from user system. target board is supplied v dd from user system. join 2-3 idle led this led is on when the evaluation chip (s3e82n0) is in idle mode. stop led this led is on when the evaluation chip (s3e82n0) is in stop mode ps031601-0813 p r e l i m i n a r y S3F82NB product specification 352
j101 com9/seg1 com7 com5 com3 com1 v lc4 v lc2 v lc0 p1.6/int6/so p1.4/int4/buz vss n.c n.c nreset p1.2/int2 p1.0/int0/av ref p0.6/ad6 p0.4/ad4 p0.2/t1out/t1pwm/t1cap/ad2 p0.0/t1clk/ad0 p6.1/cin1 p5.7/int11/seg87 p5.5/int9/seg85 p5.3/seg83 p5.1/seg81 p4.7/seg79 p4.5/seg77 p4.3/seg75 p4.1/seg73 p3.7/seg71 p3.5/seg69 p3.3/seg67 com8/seg0 com6 com4 com2 com0 v lc3 v lc1 p1.7/int7/sck p1.5/int5/si v dd n.c n.c n.c p1.3/int3 p1.1/int1 p0.7/ad7 p0.5/ad5 p0.3/ad3/t0out/t0pwm/t0cap p0.1/ad1/t0clk p6.2/cin2 p6.0/cin0 p5.6/int10/seg86 p5.4/int8/seg84 p5.2/seg82 p5.0/seg80 p4.6/seg78 p4.4/seg76 p4.2/seg74 p4.0/seg72 p3.6/seg70 p3.4/seg68 p3.2/seg66 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 64-pin dip connector figure 22-3. 64-pin connectors (j101, j102) for tb82nb ps031601-0813 p r e l i m i n a r y S3F82NB product specification 353
j102 p3.1/seg65 p2.7/seg63 p2.5/seg61 p2.3/seg59 p2.1/seg57 p7.7/seg55 p7.5/seg53 p7.3/seg51 p7.1/seg49 p8.7/seg47 p8.5/seg45 p8.3/seg43 p8.1/seg41 p9.7/seg39 p9.5/seg37 p9.3/seg35 p9.1/seg33 p10.7/seg31 p10.5/seg29 p10.3/seg27 p10.1/seg25 seg23 seg21 seg19 seg17 seg15 seg13 seg11 seg9 com15/seg7 com13/seg5 com11/seg3 p3.0/seg64 p2.6/seg62 p2.4/seg60 p2.2/seg58 p2.0/seg56 p7.6/seg54 p7.4/seg52 p7.2/seg50 p7.0/seg48 p8.6/seg46 p8.4/seg44 p8.2/seg42 p8.0/seg40 p9.6/seg38 p9.4/seg36 p9.2/seg34 p9.0/seg32 p10.6/seg30 p10.4/seg28 p10.2/seg26 p10.0/seg24 seg22 seg20 seg18 seg16 seg14 seg12 seg10 seg8 com14/seg6 com12/seg4 com10/seg2 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 64-pin dip connector figure 22-3. 64-pin connectors (j101, j102) for tb82nb (continued) ps031601-0813 p r e l i m i n a r y S3F82NB product specification 354
target board 64-pin dip connector target system j102 65 66 127 128 j101 12 63 64 target cable for 64-pin connector 64-pin dip connectors 65 66 127 128 12 63 64 j102 j101 figure 22-4. S3F82NB cables for 128-qfp package ps031601-0813 p r e l i m i n a r y S3F82NB product specification 355
third parties for development tools samsung provides a complete line of development tools for samsung's microcontroller. with long experience in developing mcu systems, our third parties are leading companies in the tool's technology. samsung in-circuit emulator solution covers a wide range of capabilities and prices, from a low cost ice to a complete system with an otp/mtp programmer. in-circuit emulator for sam8 family openice-i500 smartkit sk-1200 otp/mtp programmer spw-uni gw-uni as-pro us-pro development tools suppliers please contact our local sales offices or the 3rd party tool suppliers directly as shown below for getting development tools. 8-bit in-circuit emulator aiji system openice - i500 tel: 82-31-223-6611 fax: 82-331-223-6613 e-mail : openice@aijisystem.com url : http://www.aijisystem.com seminix sk-1200 tel: 82-2-539-7891 fax: 82-2-539-7819 e-mail: sales@seminix.com url: http://www.seminix.com ps031601-0813 p r e l i m i n a r y S3F82NB product specification 356
otp/mtp programmer (writer) spw-uni single otp/ mtp/flash programmer download/upload and data edit function pc-based operation with usb port full function regarding otp/mtp/flash mcu programmer (read, program, verify, blank, protection..) fast programming speed (4kbyte/sec) support all of samsung otp/mtp/flash mcu devices low-cost nor flash memory (sst, samsung) nand flash memory (slc) new devices will be supported just by adding device files or upgrading the software. seminix tel: 82-2-539-7891 fax: 82-2-539-7819. e-mail: sales@seminix.com url: http://www.seminix.com gw-uni gang programmer for otp/mtp/flash mcu 8 devices programming at one time download/upload and data edit function pc-based operation with usb port full function regarding otp/mtp/flash mcu programmer (read, program, verify, blank, protection..) fast programming speed (4kbyte/sec) support all of samsung otp/mtp/flash mcu devices low-cost nor flash memory (sst, samsung) nand flash memory (slc) new devices will be supported just by adding device files or upgrading the software. will be developed in march, 2008. seminix tel: 82-2-539-7891 fax: 82-2-539-7819. e-mail: sales@seminix.com url: http://www.seminix.com ps031601-0813 p r e l i m i n a r y S3F82NB product specification 357
otp/mtp programmer (writer) (continued) as-pro on-board programmer for samsung flash mcu portable & stand alone samsung otp/mtp/flash programmer for after service small size and light for the portable use support all of samsung otp/mtp/flash devices hex file download via usb port from pc very fast program and verify time ( otp:2kbytes per second, mtp:10kbytes per second) internal large buffer memory (118m bytes) driver software run under various o/s (windows 95/98/2000/xp) full function regarding otp/mtp programmer (read, program, verify, blank, protection..) two kind of power supplies (user system power or usb power adapter) support firmware upgrade seminix tel: 82-2-539-7891 fax: 82-2-539-7819. e-mail: sales@seminix.com url: http://www.seminix.com us-pro portable samsung otp/mtp/flash programmer portable samsung otp/mtp/flash programmer small size and light for the portable use support all of samsung otp/mtp/flash devices convenient usb connection to any ibm compatible pc or laptop computers. operated by usb power of pc pc-based menu-drive software for simple operation very fast program and verify time ( otp:2kbytes per second, mtp:10kbytes per second) support samsung standard hex or intel hex format driver software run under various o/s (windows 95/98/2000/xp) full function regarding otp/mtp programmer (read, program, verify, blank, protection..) support firmware upgrade seminix tel: 82-2-539-7891 fax: 82-2-539-7819. e-mail: sales@seminix.com url: http://www.seminix.com flash writing adapter board specific flash writing socket only for S3F82NB - 128qfp seminix tel: 82-2-539-7891 fax: 82-2-539-7819. e-mail: sales@seminix.com url: http://www.seminix.com ps031601-0813 p r e l i m i n a r y S3F82NB product specification 358


▲Up To Search▲   

 
Price & Availability of S3F82NB

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X